#include <bits/stdc++.h>
#pragma comment(linker, "/stack:20000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
template <typename T>
constexpr int infValue =
    std::is_same<T, int>::value ? 2000100007 : 8600000000000000007ll;
template <typename T>
constexpr int maxValue =
    std::is_same<T, int>::value ? 1000000007 : 1000000000000000001ll;
const int INF = infValue<int>;
const long long MOD = 1000000007ll;
const double EPS = 1e-6;
const int MAX = maxValue<int>;
using pr = pair<int, int>;
int n, a[200510], answ, c;
int main(void) {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", a + i);
  for (int i = 0; i < 2 * n; ++i) {
    if (a[i % n])
      ++c, answ = max(answ, c);
    else
      c = 0;
  }
  printf("%d\n", answ);
  return 0;
}
