JATC and his friend Giraffe are currently in their room, solving some problems. Giraffe has written on the board an array a_1, a_2, ..., a_n of integers, such that 1 ≤ a_1 < a_2 < … < a_n ≤ 10^3, and then went to the bathroom.

JATC decided to prank his friend by erasing some consecutive elements in the array. Since he doesn't want for the prank to go too far, he will only erase in a way, such that Giraffe can still restore the array using the information from the remaining elements. Because Giraffe has created the array, he's also aware that it's an increasing array and all the elements are integers in the range [1, 10^3].

JATC wonders what is the greatest number of elements he can erase?

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 100) — the number of elements in the array.

The second line of the input contains n integers a_i (1 ≤ a_1<a_2<...<a_n ≤ 10^3) — the array written by Giraffe.

Output

Print a single integer — the maximum number of consecutive elements in the array that JATC can erase.

If it is impossible to erase even a single element, print 0.

Examples

Input

6
1 3 4 5 6 9


Output

2

Input

3
998 999 1000


Output

2

Input

5
1 2 3 4 5


Output

4

Note

In the first example, JATC can erase the third and fourth elements, leaving the array [1, 3, \\_, \\_, 6, 9]. As you can see, there is only one way to fill in the blanks.

In the second example, JATC can erase the second and the third elements. The array will become [998, \\_, \\_]. Because all the elements are less than or equal to 1000, the array is still can be restored. Note, that he can't erase the first 2 elements.

In the third example, JATC can erase the first 4 elements. Since all the elements are greater than or equal to 1, Giraffe can still restore the array. Note, that he can't erase the last 4 elements.


import java.io.*;
import java.util.*;

/**
 *  
 * @author akash_2ehuikg
 * Coding is love <3!
 */

public class A {
    public static void main(String args[]) {
        try {
            int n =nextInt();
            int A[]=new int[n];
            
            for (int i = 0; i < n; i++) {
                A[i]=nextInt();
            }
            
            int ans=0;
            int count=0;
            for (int i = 1; i <n-1; i++) {
                if(A[i]+1==A[i+1] && A[i]-1==A[i-1]){
                    count++;
                    if(i==1 && A[0]==1)count++;
                    
                    if(i==n-2 && A[n-1]==1000)count++;
                }else{
                    ans=Math.max(count,ans);
                    count=0;
                }
             //   System.out.println(""+count);
            }
            
            ans=Math.max(count, ans);
            
            if(n>1 && A[0]==1 && A[1]==2)ans=Math.max(ans, 1);
                
            if(n>1 && A[n-2]==999 && A[n-1]==1000)ans=Math.max(ans,1);
            
            bw.write(ans+"\n");
            bw.flush();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    //TEMPLATE
    
    //******************************************************************************
    // Fast I/O 
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
    static StringTokenizer st = null;
    static int mod=1000000007;

    static String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }
    
    static int nextInt() {
        return Integer.parseInt(next());
    }
    
    static long nextLong() {
        return Long.parseLong(next());
    }

    static double nextDouble() {
        return Double.parseDouble(next());
    }

    static int b_search(int l,int r,int A[],int key){
        int ans=0;
        l=0;r=1000000000;

        while(l<r){
            //System.out.println(ans);
            ans=(l+r)/2;
            long temp=0;
            for (int i = 0; i < A.length; i++) {
                temp+=(long)Math.ceil((double)A[i]/(double)ans);
            }

            if(temp<=key){
                r=ans;
            }
            else{
                l=ans+1;
                ans=r;
            }
        }

        return ans;
    }

//******************************************************************************
//Modulo and FastExpo
    static long modInverse(long a)
    {
       return power(a, mod - 2,mod);
    }
     
    // To compute x^y under modulo m
    static long power(long x, long y, int p)
    {
        // Initialize result
        long res = 1;     
        // Update x if it is more  
        // than or equal to p
        x = x % p; 
     while (y > 0)
        {
            // If y is odd, multiply x
            // with result
            if((y & 1)==1)
                res = (res * x) % p;
            // y must be even now
            // y = y / 2
            y = y >> 1; 
            x = (x * x) % p; 
        }
        return res;
    }
//******************************************************************************
//GCD
    static long gcd(long a, long b)
    {
        if (a == 0)
            return b;
         
        return gcd(b%a, a);
    }

    //******************************************************************************
    // Useful user datatype
    
    static class Pair{
        public long x;
        public long y;

        public Pair(long first, long second){
            this.x = first;
            this.y = second;
            }
        @Override
        public String toString() {
        return "(" + x + "," + y + ")";
        }
    }

    static Comparator csort=new Comparator<Pair>(){
                    public int compare(Pair a, Pair b) {
                        if(a.x < b.x)
                        return -1;
                        else if (a.x > b.x)
                        return 1;
                        else if(a.y < b.y)
                        return -1;
                        else if (a.y > b.y)
                        return 1;
                        else
                        return 0;
                    }
                };

    //******************************************************************************
    //N choose K
    public static long choose(long total, long choose){
        if(total < choose)
            return 0;
        if(choose == 0 || choose == total)
            return 1;
        return choose(total-1,choose-1)+choose(total-1,choose);
    }

    //******************************************************************************
    //Permutations
    // simply prints all permutation - to see how it works
    private static void printPermutations( Comparable[] c ) {
            System.out.println( Arrays.toString( c ) );
            while ( ( c = nextPermutation( c ) ) != null ) {
                    System.out.println( Arrays.toString( c ) );
            }
    }

    // modifies c to next permutation or returns null if such permutation does not exist
    private static Comparable[] nextPermutation( final Comparable[] c ) {
            // 1. finds the largest k, that c[k] < c[k+1]
            int first = getFirst( c );
            if ( first == -1 ) return null; // no greater permutation
            // 2. find last index toSwap, that c[k] < c[toSwap]
            int toSwap = c.length - 1;
            while ( c[ first ].compareTo( c[ toSwap ] ) >= 0 )
                    --toSwap;
            // 3. swap elements with indexes first and last
            swap( c, first++, toSwap );
            // 4. reverse sequence from k+1 to n (inclusive) 
            toSwap = c.length - 1;
            while ( first < toSwap )
                    swap( c, first++, toSwap-- );
            return c;
    }

    // finds the largest k, that c[k] < c[k+1]
    // if no such k exists (there is not greater permutation), return -1
    private static int getFirst( final Comparable[] c ) {
            for ( int i = c.length - 2; i >= 0; --i )
                    if ( c[ i ].compareTo( c[ i + 1 ] ) < 0 )
                            return i;
            return -1;
    }

    // swaps two elements (with indexes i and j) in array 
    private static void swap( final Comparable[] c, final int i, final int j ) {
            final Comparable tmp = c[ i ];
            c[ i ] = c[ j ];
            c[ j ] = tmp;
    }
    //******************************************************************************
    // DSU
    //Maintain an Array A with N elements and Array size for size of each set, intialize A[i]=i and size[i]=1

    static int root(int A[],int i){
        while(A[i]!=i){
            A[i]=A[A[i]];
            i=A[i];
        }
        return i;
    }

    static boolean find(int A[],int a,int b){
        if(root(A,a)==root(A,b))return true;
        else return false;
    }

    static void union(int A[],int size[],int a,int b){
        int ra=root(A,a);
        int rb=root(A,b);

        if(ra==rb)return;

        if(size[ra]<size[rb]){
            A[ra]=A[rb];
            size[rb]+=size[ra];
        }else{
            A[rb]=A[ra];
            size[ra]+=size[rb];
        }
    }

    //**************************************************************************
    //BinarySearch
    /* binary search for 5:
                v-- lower bound
         1 2 3 4 5 5 5 6 7 9
                      ^-- upper bound
        
            binary search for 8
                        v-- lower bound
       1 2 3 4 5 5 5 6 7 9
                        ^-- upper bound
    */
    //For finding greater than 
    static int upper_bound(int A[],int key){
        int first = 0;
        int last = A.length;
        int mid;

        while (first < last) {
            mid =first+(last - first)/2; 

            if (A[mid] <= key)  
                first = mid + 1; 
            else 
                last = mid;
        }

        return first;
    }
    
    //For finding greater than equal to
    static int lower_bound(int A[],int key){
        int first = 0;
        int last = A.length;
        int mid=0;
        
        while (first < last) {
            mid = first + ((last - first) >> 1); 
            if (A[mid] < key)  
                first = mid + 1; 
            else 
                last = mid;
        }
        
        return first;
    }
    //**************************************************************************
}
