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 \le a_1 < a_2 < \ldots < a_n \le 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 \le n \le 100$) — the number of elements in the array.

The second line of the input contains $n$ integers $a_i$ ($1 \le a_1<a_2<\dots<a_n \le 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.

Difficulty: interview

Starter code:

Solutions:
n = int(input())
a = [0] + list(map(int, input().split())) + [1001]
mx = 1
p = 1
for i in range(1, n + 2):
    if a[i] == a[i - 1] + 1:
        p += 1
        mx = max(p, mx)
    else:
        p = 1
print(max(0, mx - 2))

n = int(input())
arr = [0] + list(map(int, input().split()))
arr.append(1001)
max_ = 0
kek = 0
for i in range(1, len(arr)):
    if arr[i] - 1 == arr[i - 1]:
        kek += 1
    else:
        max_ = max(max_, kek - 1)
        kek = 0
max_ = max(max_, kek - 1)
print(max_)


def ii():
    return int(input())
def mi():
    return map(int, input().split())
def li():
    return list(mi())

n = ii()
a = li()
a = [0] + a + [1001]
ans = 0
i = 0
while i <= n:
    j = i + 1
    while j <= n + 1 and a[j] == a[j - 1] + 1:
        j += 1
    ans = max(ans, j - i - 2)
    i = j
print(ans)

#int(input())
#map(int,input().split())
#[list(map(int,input().split())) for i in range(q)]
#print("YES" * ans + "NO" * (1-ans))
n = int(input())
ai = [0] + list(map(int,input().split())) + [1001]
ans = 0
num = 1
for i in range(1,n+2):
    if ai[i] == ai[i-1]+1:
        num += 1
    else:
        ans = max(ans,num - 2)
        num = 1
print(max(ans,num - 2))


n = int(input())
a = [0]
a.extend(list(map(int, input().split())))
a.append(1001)

longest = 0
i = 0

while i < len(a):
    j = i + 1
    while j < len(a) and a[j-1] + 1 == a[j]:
        j += 1
    current = j - i - 2
    longest = max(longest, current)
    i = j

print(longest)



def main():
    buf = input()
    n = int(buf)
    buf = input()
    buflist = buf.split()
    a = list(map(int, buflist))
    a.insert(0, 0)
    a.append(1001)
    count = -1
    max_count = 0
    last_number = None
    for i, number in enumerate(a):
        if last_number == None:
            pass
        elif number == last_number + 1:
            count += 1
            if count > max_count:
                max_count = count
        else:
            count = -1
        last_number = number
    print(max_count)


def __starting_point():
    main()

__starting_point()

n = int(input())
n += 2
a = list(map(int, input().split()))
a = [0] + a
a = a + [1001]
ind = 0
ans = 0
while ind != n:
    now = 0
    while ind + 1 != n and a[ind] + 1 == a[ind + 1]:
        ind += 1
        now += 1
    ind += 1
    ans = max(ans, now - 1)
print(ans)


n=int(input())
s=input().split()
l=[0]+[int(s[i]) for i in range(n)]+[1001]
maxlen=0
prev=0
cnt=1
for i in range(1,n+2):
    if prev==l[i]-1:
        cnt+=1
    else:
        maxlen=max(maxlen,cnt-2)
        cnt=1
    prev=l[i]
maxlen=max(maxlen,cnt-2)
print(maxlen)


n = int(input())
arr = [int(x) for x in input().split()]
ma = 0
cnt = 0
if len(arr) == 1000:
    print(1000)
else:
    for i in range(len(arr) - 1):
        if arr[i + 1] == arr[i] + 1:
            cnt += 1
            if arr[i] == 1 or arr[i + 1] == 1000:
                cnt += 1
        else:
            ma = max(ma, cnt)
            cnt = 0
ma = max(ma, cnt)
print(max(0, ma - 1))

n = int(input())
arr = list(map(int, input().split()))
ans = 0
for i in range(n):
	for j in range(i + 2, n):
		if arr[j] - arr[i] == j - i:
			ans = max(ans, j - i - 1)
for i in range(n):
	if arr[i] == i + 1:
		ans = max(ans, i)
for i in range(n):
	if n - i - 1 == 1000 - arr[i]:
		ans = max(ans, n - i - 1)
print(ans)

n = int(input())
a = list(map(int, input().split()))
x = 0
for i in range(n):
    if a[i] == 1:
        xm = 2
    else:
        xm = 1
    for j in range(i+1, n):
        if a[j]-a[j-1] == 1:
            xm += 1
            if a[j] == 1000:
                xm += 1
        else:
            break
    x = max(x, xm-2)
print(x)

n = int(input())
arr = [0] + [int(x) for x in input().split()] + [1001]

arr2 = []
for a, b in zip(arr, arr[1:]):
  arr2.append(b-a)

longest = 0
current = 0
for x in arr2:
  if x == 1:
    current += 1
  else:
    longest = max(longest, current)
    current = 0
longest = max(longest, current)

print(max(longest - 1, 0))


n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(0, n):
    for j in range(i + 1, n):
        if a[j] - a[i] == j - i:
            if a[j] == 1000 or a[i] == 1 and not (a[j] == 1000 and a[i] == 1):
                ans = max(j - i, ans)
            if a[j] == 1000 and a[i] == 1:
                ans = 1000
            else:
                ans = max(j - i - 1, ans)
print(ans)


#!/usr/bin/env python3
from typing import Dict, List, Tuple


def input_lst() -> List[int]:
    return [int(x) for x in input().split()]

def print_out(res: List[int]):
    print(' '.join([str(x) for x in res]))


def main():
    n,  = (int(x) for x in input().split())
    a = input_lst()

    l = 0
    l_max = 0
    if a[0] == 1:
        l+=1

    for i in range(n-1):
        if a[i+1] - a[i] == 1:
            l+=1
        else:
            if l>0:
                l_max = max(l, l_max)
                l = 0

    if l > 0:
        if a[-1] == 1000:
            l+=1
        l_max = max(l, l_max)

    print(max(l_max-1, 0))

def __starting_point():
    main()

__starting_point()

n = int(input())
a = [0] + [int(i) for i in input().split()] + [1001]
ans = 0
for j in range(1, n + 1):
    i = j
    f = 0
    while i < n + 1 and a[i] == a[i - 1] + 1 and a[i] == a[i + 1] - 1:
        f += 1
        i += 1
    ans = max(ans, f)
print(ans)

import sys
input_file = sys.stdin

n = int(input_file.readline())
lst = [0] + list(int(i) for i in input_file.readline().split()) + [1001]
#print(n, lst)
maxi = 1
ans = 1
for i in range(1, len(lst)):
    if lst[i] == lst[i-1] + 1:
        ans += 1
    else:
        #print(ans)
        maxi = max(maxi, ans)
        ans = 1
maxi = max(maxi, ans)
        

print(max(maxi-2, 0))
    


n=int(input())
A=list(map(int,input().split()))
A=[0]+A+[1001]

ANS=0
count=0
for i in range(1,n+1):
    if A[i]==A[i-1]+1 and A[i]==A[i+1]-1:
        count+=1
    else:
        ANS=max(ANS,count)
        count=0

ANS=max(ANS,count)
print(ANS)


n = int(input())
s = list(map(int, input().split()))
s = [0] + s[:] + [1001]
c = 0
maxc = 0
for i in range(1, len(s)):
	if s[i] - s[i - 1] == 1:
		c += 1
		if c > maxc:
			maxc = c-1
	else:
		c = 0
print(maxc)

from sys import stdin, stdout
from math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial

n = int(stdin.readline())
vl = list(map(int, stdin.readline().split()))
ans = 0

for i in range(n):
    cnt = 0
    while i + cnt < n and vl[i + cnt] == vl[i] + cnt:
        cnt += 1
    
    ans = max(ans, cnt - 2)
        

cnt1 = 0
while cnt1 < n and vl[cnt1] == cnt1 + 1:
    cnt1 += 1

cnt2 = 0
while cnt2 < n and vl[n - 1 - cnt2] == 10 ** 3 - cnt2:
    cnt2 += 1

ans = max(ans, max(cnt1, cnt2) - 1)
stdout.write(str(ans))

# use this as the main template for python problems
from collections import Counter

def solution(n, arr):
    arr = [0] + arr
    arr.append(1001)
    
    best = 0
    count = 0
    for ind, val in enumerate(arr[:-2]):
        if(val+1 == arr[ind+1] and (val+2 == arr[ind+2])):
            count += 1
        else:
            if(best < count):
                best = count
            count = 0
    print(max(best, count))


def __starting_point():

    # single variables
    n = [int(val) for val in input().split()][0]

    # vectors
    arr = [int(val) for val in input().split()]

    # solve it!
    solution(n, arr)


__starting_point()

n = int(input())
a = list(map(int, input().split()))
a = [0] + a + [1001]

ans = 0
for i in range(len(a)):
    for j in range(i + 3, len(a) + 1):
        if a[i : j] == list(range(a[i], a[i] + j - i)):
            ans = max(ans, j - i - 2)

print(ans)

n = int(input())
a = [0] + list(map(int, input().split())) + [1001]
max_ans = 0
ans = 0

for i in range(1, len(a) - 1):
    #print('cur' , a[i])
    if a[i] == a[i - 1] + 1 and a[i] == a[i + 1] - 1:
        ans += 1
        #print('+1')
    else:
        #print(a[i], ans, max_ans)
        #print(max(ans, max_ans))
        max_ans = max(ans, max_ans)
        ans = 0

print(max(max_ans, ans))


def user99():
    n = int(input())
    a = list(map(int, input().split()))
    b = [[] for i in range(n)]

    ptr = 0
    for i in range(n):
        if i >= 1 and a[i - 1] + 1 != a[i]:
            ptr += 1
        b[ptr].append(a[i])

    ans = 0
    for i in b:
        if len(i) == 0:
            continue;
        x = len(i) - 2
        if i[0] == 1: x += 1
        if i[-1] == 10**3: x += 1
        ans = max(ans, x)

    print(ans)

user99()

n = int(input())
A = [0] + list(map(int,  input().split())) + [1001]

c = 0
ans = 0
for i in range(1,n+1):
  if A[i]-1 == A[i-1] and A[i]+1 == A[i+1]:
    c += 1
  else:
    c = 0

  ans = max(ans, c)

print(ans)
 



n = int(input())
a  = [0] + list(map(int, input().split())) + [1001]
res = 1
cur = 1

for i in range(n+1):
    if a[i+1] - a[i] == 1:
        cur += 1
    else:
        cur = 1
    res  = max(res, cur)
print(max(0, res - 2))