#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int i, ans;
  vector<int> a(n);
  vector<int> b(n);
  b[0] = 0;
  for (i = 0; i < n; i++) cin >> a[i];
  for (i = 1; i < n; i++) b[i] = a[i - 1] + b[i - 1];
  for (i = 3; i < n; i++) ans = max(ans, b[i] - b[i - 3]);
  cout << ans << endl;
  return 0;
}
