#include using namespace std; int* dp; long my_func(int n){ if(n==1) return 0; if(dp[n]) return dp[n]; int i; int64_t sol=0; for(i=1;isol) sol=temp; } dp[n]=sol; return sol; } long longestSequence(vector a) { // Return the length of the longest possible sequence of moves. long sol=0; for(int i=0;i> n; vector a(n); int mark=0; for(int a_i = 0; a_i < n; a_i++){ cin >> a[a_i]; if(a[a_i]>mark) mark=a[a_i]; } dp=(int*)calloc(sizeof(int),mark+1); long result = longestSequence(a); cout << result << endl; return 0; }