#include #define be(v) (v).begin(),(v).end() #define pb(q) push_back(q) #define era(t) t.erase(unique(be(t)),t.end()) #define doublecout(a) cout<inline T lcm(T a,T b){return (a*b/__gcd(a,b));} int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin>>n; int a[n]; for(int i=0;i>a[i]; } int dp[n]; for(int i=0;i=0;j--){ maki=max(dp[j],maki); } dp[i]+=maki; } int ans=(n==1)?dp[n-1]:max(dp[n-1],dp[n-2]); cout << ans<