#include #include using namespace std; int main() { int N; cin >> N; vector V(N); for (int i = 0; i < N; i++) { cin >> V[i]; } int max = 0; if (N == 1) max = V[0]; else { for (int i = 0; i < N-1; i++) { if (V[2*i] > V[2*i+1]) max += V[2*i]; else max += V[2*i+1]; } } cout << max << endl; return 0; }