#include <bits/stdc++.h>
using namespace std;
int a[200001];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int ans = 0;
  int count1 = 0, count2 = 0, count = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == 1) {
      count1++;
    } else {
      break;
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    if (a[i] == 1) {
      count2++;
    } else {
      break;
    }
  }
  for (int i = 0; i < n; i++) {
    if (a[i] == 1) {
      count++;
    } else {
      ans = max(ans, count);
      count = 0;
    }
  }
  ans = max(ans, count1 + count2);
  cout << ans << endl;
  return 0;
}
