Each day in Berland consists of n hours. Polycarp likes time management. That's why he has a fixed schedule for each day — it is a sequence a_1, a_2, ..., a_n (each a_i is either 0 or 1), where a_i=0 if Polycarp works during the i-th hour of the day and a_i=1 if Polycarp rests during the i-th hour of the day.

Days go one after another endlessly and Polycarp uses the same schedule for each day.

What is the maximal number of continuous hours during which Polycarp rests? It is guaranteed that there is at least one working hour in a day.

Input

The first line contains n (1 ≤ n ≤ 2⋅10^5) — number of hours per day.

The second line contains n integer numbers a_1, a_2, ..., a_n (0 ≤ a_i ≤ 1), where a_i=0 if the i-th hour in a day is working and a_i=1 if the i-th hour is resting. It is guaranteed that a_i=0 for at least one i.

Output

Print the maximal number of continuous hours during which Polycarp rests. Remember that you should consider that days go one after another endlessly and Polycarp uses the same schedule for each day.

Examples

Input


5
1 0 1 0 1


Output


2


Input


6
0 1 0 1 1 0


Output


2


Input


7
1 0 1 1 1 0 1


Output


3


Input


3
0 0 0


Output


0

Note

In the first example, the maximal rest starts in last hour and goes to the first hour of the next day.

In the second example, Polycarp has maximal rest from the 4-th to the 5-th hour.

In the third example, Polycarp has maximal rest from the 3-rd to the 5-th hour.

In the fourth example, Polycarp has no rest at all.

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.ObjectInputStream.GetField;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.text.CollationKey;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main {
	static class edge {
		long op;
		long cl;
		long v;

		public edge(long i, long j, long val) {
			op = i;
			cl = j;
			v = val;
		}

	}

	public static class SegmentTree { // 1-based DS, OOP

		int N; // the number of elements in the array as a power of 2 (i.e.
				// after
				// padding)
		int val = 0;
		int left = 0;
		int right = 0;
		long[] open, close, sTree, lazy, value;
		boolean[] array;

		public SegmentTree(boolean[] c)

		{
			array = c;
			N = array.length - 1;
			value = new long[N << 1];
			open = new long[N << 1]; // no. of nodes = 2*N - 1, we add one to
			close = new long[N << 1]; // cross out index zero
			lazy = new long[N << 1];

			build(1, 1, N);
		}

		public void build(int node, int b, int e) // O(n)
		{
			if (b == e) {
				if (array[b])
					open[node] = 1;
				else
					close[node] = 1;
			} else {
				int mid = b + e >> 1;
				build(node << 1, b, mid);
				build(node << 1 | 1, mid + 1, e);
				// sTree[node] = Math.min(sTree[node << 1], sTree[node << 1 |
				// 1]);
				long x = open[node << 1];
				long y = close[node << 1 | 1];
				if (x > y) {
					value[node] = value[node << 1] + value[node << 1 | 1] + y;
					open[node] = x - y + open[node << 1 | 1];
					close[node] = close[node << 1];
				} else {
					value[node] = value[node << 1] + value[node << 1 | 1] + x;
					open[node] = open[node << 1 | 1];
					close[node] = y - x + close[node << 1];
				}
			}
		}

		public void update_point(int index, int val) // O(log n)
		{
			index += N - 1;
			sTree[index] += val;
			while (index > 1) {
				index >>= 1;
				sTree[index] = sTree[index << 1] + sTree[index << 1 | 1];
			}
		}

		public void update_range(int i, int j, int val) // O(log n)
		{
			update_range(1, 1, N, i, j, val);
		}

		public void update_range(int node, int b, int e, int i, int j, int val) {
			if (i > e || j < b)
				return;
			if (b >= i && e <= j) {
				sTree[node] += val * 1l;
				lazy[node] += val * 1l;
			} else {
				int mid = b + e >> 1;
				propagate(node, b, mid, e);
				update_range(node << 1, b, mid, i, j, val);
				update_range(node << 1 | 1, mid + 1, e, i, j, val);
				sTree[node] = Math.min(sTree[node << 1], sTree[node << 1 | 1]);
			}
		}

		public void propagate(int node, int b, int mid, int e) {
			lazy[node << 1] += lazy[node];
			lazy[node << 1 | 1] += lazy[node];
			sTree[node << 1] += lazy[node];
			sTree[node << 1 | 1] += lazy[node];
			lazy[node] = 0;

		}

		public edge query(int i, int j)

		{

			return query(1, 1, N, i, j);

		}

		public edge query(int node, int b, int e, int i, int j) {
			if (i > e || j < b)
				return null;
			if (b >= i && e <= j)
				return new edge(open[node], close[node], value[node]);
			int mid = (b + e) >> 1;
			// propagate(node, b, mid, e);
			edge q1 = query(node << 1, b, mid, i, j);
			edge q2 = query(node << 1 | 1, mid + 1, e, i, j);
			if (q1 == null)
				return q2;

			if (q2 == null)
				return q1;

			long x = q1.op;
			long y = q2.cl;
			if (x > y)
				return new edge(x - y + q2.op, q1.cl, y + q1.v + q2.v);
			else
				return new edge(q2.op, q1.cl + y - x, x + q1.v + q2.v);

		}
	}

	static PrintWriter pw;

	public static long power(long u, long v) {
		long ans = 1;
		for (int i = 0; i < v; i++) {
			ans *= u;
		}
		return ans;
	}

	public static int ch(int k, int n, int[] Arr) {
		for (int i = 0; i < Arr.length; i++) {
			if (Arr[i] <= n)
				k--;
		}
		if (k == 0)
			return 0;
		if (k > 0)
			return 1;
		return 2;
	}

	public static void main(String[] args) throws IOException, InterruptedException {
		// FileWriter f = new FileWriter("C:\\Users\\Hp\\Desktop\\out.txt");
		// PrintWriter pw = new PrintWriter(f);
		pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
//		int m = sc.nextInt();
		int[]Arr=new int[n];
		for(int i=0;i<n;i++){
			Arr[i]=sc.nextInt();
		}
		int count=0;
		int max=0;
		for(int i=0;i<n;i++){
			if(Arr[i]==1){
				count++;
			}
			else{
				max=Math.max(max, count);
				count=0;
			}
		}
		for(int i=0;i<n;i++){
			if(Arr[i]==1){
				count++;
			}
			else{
				max=Math.max(max, count);
				count=0;
				break;
			}
		}
		System.out.println(max);
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}

}
