#include <bits/stdc++.h>
int main() {
  ;
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(0);
  ;
  int n;
  std::cin >> n;
  ;
  ;
  int t = 1, max = 0, left = 0, curr = 0;
  while (n-- && t) {
    std::cin >> t;
    if (t)
      ++curr;
    else {
      max = curr;
      left = curr;
      curr = 0;
    }
  }
  if (t == 0) ++n;
  while (n--) {
    std::cin >> t;
    if (t) {
      if (curr)
        ++curr;
      else {
        curr = 1;
      }
    } else {
      if (curr) {
        max = std::max(curr, max);
        curr = 0;
      }
    }
  }
  max = std::max(curr, max);
  if (curr)
    std::cout << std::max(left + curr, max);
  else
    std::cout << max;
  ;
  ;
  return 0;
  ;
}
