#include <bits/stdc++.h>
using namespace std;
long long n, m;
long long ar[200000];
bool p = false;
int main() {
  cin >> n;
  long long ans = 0;
  long long t = 0;
  long long s = 0;
  bool p = true;
  for (int i = 1; i <= n; i++) {
    cin >> ar[i];
    if (p) {
      s += ar[i];
    }
    if (ar[i] == 0) {
      p = false;
    }
    if (ar[i] == 1) {
      ar[i] += ar[i - 1];
    }
    ans = max(ans, ar[i]);
  }
  cout << max(ans, s + ar[n]);
}
