#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i;
  cin >> n;
  long long arr[n];
  for (i = 0; i < n; i++) {
    cin >> arr[i];
  }
  long long maxm = 0, count = 0, idx = 0;
  for (i = 0; i < n; i++) {
    if (arr[i] == 1)
      count++;
    else
      break;
  }
  idx = i;
  for (i = n - 1; i >= 0; i--) {
    if (arr[i] == 1)
      count++;
    else
      break;
  }
  if (count > maxm) maxm = count;
  for (i = idx; i < n; i++) {
    if (arr[i] == 1)
      count++;
    else {
      if (count > maxm) maxm = count;
      count = 0;
    }
  }
  cout << maxm;
  return 0;
}
