#include using namespace std; int n; long longestSequence(vector a) { // Return the length of the longest possible sequence of moves. int i,grand=0; for(i=0;i1) { l=l/2; tot+=l; } tot+=a[i]; } else { tot=1+a[i]; } grand+=tot; } return grand; } int main() { cin >> n; vector a(n); for(int a_i = 0; a_i < n; a_i++){ cin >> a[a_i]; } long result = longestSequence(a); cout << result << endl; return 0; }