#C7688. Maximum Consecutive Available Timeslots

    ID: 51586 Type: Default 1000ms 256MiB

Maximum Consecutive Available Timeslots

Maximum Consecutive Available Timeslots

You are given a series of timeslots represented by an array of integers. In this array, 0 denotes an available timeslot while 1 denotes a booked one. Your task is to determine the length of the longest contiguous segment of available timeslots.

Formally, given an array a of length n, you need to compute:

maxsegment  length,\max_{\text{segment}} \; \text{length},

where the segment consists solely of zeros. If the array is empty or no available timeslot exists, the answer is 0.

inputFormat

The input is given via standard input and consists of two parts:

  1. The first line contains an integer n representing the number of timeslots.
  2. If n > 0, the second line contains n space-separated integers (each either 0 or 1), representing the timeslots.

If the array is empty, n will be 0 and there will be no second line.

outputFormat

Output a single integer to standard output, which is the length of the longest contiguous segment of available timeslots.

## sample
9
1 0 0 1 0 0 0 1 0
3