D. Christmas Express
The Christmas Express is a train that transports passengers around the circular metro of the North Pole. This metro consists of stations, numbered consecutively from to . The train stops at stations in the order , continuing indefinitely.
Based on data from the past two years, Grandpa Frost has observed that each time the train stops at station , a certain number of elves, , board the train and travel to station , for every where . Grandpa Frost needs to determine the minimum number of seats required on the train to accommodate all passengers comfortably.
It is assumed that at each station, passengers disembark before new passengers board. Your task is to assist Grandpa Frost in finding the solution.
Input
The first line contains a single integer (), representing the number of stations.
Each of the following lines contains integers (), where all are .
Output
Output a single integer — the minimum number of seats required on the train.
Examples
Note
For example, if the train can only carry eight passengers at a time, it will not be sufficient for all elves. However, nine seats would be enough to accommodate them comfortably.