This page is still under construction.

Parts of this page are still being built. What you see may change.

Handshakes

Time limit2sMemory limit512 MB

Summary
Given each employee's handshake count with earlier arrivals, find the largest possible number of friends any single employee can have.
Level

Medium7 of 10

Topics
Greedy, Graph, Array, Implementation
Solved
No attempts yet

Problem

A large company employs nn people. The employees are numbered with consecutive integers from 11 to nn in the order they arrive at work each day. No two employees arrive at the same time, so employee 11 arrives first, employee 22 arrives second, and so on.

Some pairs of employees are friends, and friendship is symmetric: if employee ii considers employee jj a friend, then employee jj also considers employee ii a friend. When an employee arrives at work, he quickly walks around the office and shakes hands with all of his friends who are already in the office, that is, those who arrived before him. It is not known which pairs of employees are friends, but for each employee the number of handshakes he makes each day right after arriving at work is known.

The director of the company wants to talk with one of the employees about the current state of affairs. For this he wants to choose the most socially active person, namely the employee with the most friends. Using the available information, determine the maximum number of friends that one of the employees can have.

Input

The first line of the input contains a single number nn (1≤n≤200 0001 \leq n \leq 200\,000), the number of employees in the company.

The second line of the input contains nn integers h_ih\_i (0≤h_i<i0 \leq h\_i < i). The ii-th number is the number of handshakes that employee ii made right after arriving at work, that is, before employee i+1i + 1 arrived.

Output

Print a single number: the maximum possible number of friends of one of the company's employees.

Notes

In the first example there is only one pair of employees, and they are friends, as follows from h_2=1h\_2 = 1.

In the second example, if employees 33, 44, and 55 all shook hands with the same employee, then that employee has 33 friends.

Examples2

  1. Example 1

    Input
    2
    0 1
    
    Expected output
    1
    
  2. Example 2

    Input
    5
    0 0 1 1 1
    
    Expected output
    3