Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter
from operator import mul
import copy

n, k, l = list(map(int, input().split()))

road = [[] for i in range(n+1)]
rail = [[] for i in range(n+1)]

for i in range(k):
    p, q = list(map(int, input().split()))
    road[p].append(q)
    road[q].append(p)

for i in range(l):
    r, s = list(map(int, input().split()))
    rail[r].append(s)
    rail[s].append(r)

seen = [0 for i in range(n+1)]

def dfs_stack(u, al):
    stack = deque([u])
    seen[u] = 1
    visited = []

    while len(stack) > 0:
        v = stack.pop()
        ###
        visited.append(v)
        ###

        for w in al[v]:
            if seen[w] == 0:
                stack.append(w)
                seen[w] = 1

        if stack == []: break

    return visited

road_c = []
rail_c = []
for i in range(1,n+1):
    if seen[i] == 0:
        road_c.append(dfs_stack(i, road))

seen = [0 for i in range(n+1)]

for i in range(1,n+1):
    if seen[i] == 0:
        rail_c.append(dfs_stack(i, rail))

ans = [0 for i in range(n+1)]
for a in road_c:
    for b in rail_c:
        intersection = set(a) & set(b)
        for i in intersection:
            ans[i] = str(len(intersection))

print(' '.join(ans[1:]))


### FIXED CODE ###

from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter
from operator import mul
import copy

n, k, l = list(map(int, input().split()))

road = [[] for i in range(n+1)]
rail = [[] for i in range(n+1)]

for i in range(k):
    p, q = list(map(int, input().split()))
    road[p].append(q)
    road[q].append(p)

for i in range(l):
    r, s = list(map(int, input().split()))
    rail[r].append(s)
    rail[s].append(r)

seen = [0 for i in range(n+1)]

def dfs_stack(u, al, al_c, d):
    stack = deque([u])
    seen[u] = 1

    while len(stack) > 0:
        v = stack.pop()
        ###
        al_c[v] = d
        ###

        for w in al[v]:
            if seen[w] == 0:
                stack.append(w)
                seen[w] = 1

        if stack == []: break


road_c = [-1 for i in range(n+1)]
rail_c = [-1 for i in range(n+1)]

d = 0
for i in range(1,n+1):
    if seen[i] == 0:
        dfs_stack(i, road, road_c, d)
        d += 1

seen = [0 for i in range(n+1)]

d = 0
for i in range(1,n+1):
    if seen[i] == 0:
        dfs_stack(i, rail, rail_c, d)
        d += 1

dict = {}

for i in range(1, n+1):
    if (road_c[i], rail_c[i]) not in dict:
        dict[(road_c[i], rail_c[i])] = [i]
    else:
        dict[(road_c[i], rail_c[i])].append(i)

ans = [0 for i in range(n+1)]

for dd in dict.items():
    for j in dd[1]:
        ans[j] = str(len(dd[1]))

print(' '.join(ans[1:]))
### BUGGY CODE ###

N,M=map(int,input().split())
mod=10**9+7

from math import factorial
from collections import Counter

def soinsuu(n):
    list_=[]
    while(n!=1):
        for i in range(2,int(n**0.5)+1):
            if n%i==0:
                list_.append(i)
                n=n//i
                break
        else:
            list_.append(n)
            n=1
    return sorted(list_)

def product(a):
    pro=1
    for b in a:
        pro=pro*b%mod
    return pro

#n!,nPr,nCrの高速計算
def n_func(n,mod=10**9+7):
    ans=1
    for i in range(1,n+1):
        ans=(ans*i)%mod
    return ans
def inv_n(n,mod=10**9+7):
    return pow(n,mod-2,mod)
def nPr(n,r,mod=10**9+7):
    ans=n_func(n-r,mod)
    ans=inv_n(ans,mod)
    return ans*n_func(n,mod)%mod

def dp(cur,init,seq,lest,num):
    if cur==N:
        if lest==0:
            cnt=list(Counter(seq).values())
            bunbo=product(map(factorial,cnt[1:]))
            memo[num]=(memo[num]+nPr(sum(cnt),sum(cnt[1:]),mod)*inv_n(bunbo))%mod
    elif lest==0:
        dp(N,init,seq+[0]*(N-cur),0,num)
    else:
        for i in range(1,lest+1):
            if cur==0:
                dp(cur+1,init,seq+[i],lest-i,num)
            elif i<=seq[-1]:
                dp(cur+1,init,seq+[i],lest-i,num)

p=list(Counter(soinsuu(M)).values())
memo=[0]*len(p)

for i in range(len(p)):
    dp(0,p[i],[],p[i],i)
print(product(memo))

### FIXED CODE ###

N,M=map(int,input().split())
mod=10**9+7
 
from math import factorial
from collections import Counter
 
def soinsuu(n):
    list_=[]
    while(n!=1):
        for i in range(2,int(n**0.5)+1):
            if n%i==0:
                list_.append(i)
                n=n//i
                break
        else:
            list_.append(n)
            n=1
    return sorted(list_)
 
def product(a):
    pro=1
    for b in a:
        pro=pro*b%mod
    return pro
 
#n!,nPr,nCrの高速計算
def n_func(n,mod=10**9+7):
    ans=1
    for i in range(1,n+1):
        ans=(ans*i)%mod
    return ans
def inv_n(n,mod=10**9+7):
    return pow(n,mod-2,mod)
def nPr(n,r,mod=10**9+7):
    ans=n_func(n-r,mod)
    ans=inv_n(ans,mod)
    return ans*n_func(n,mod)%mod
    
nPr_list=[nPr(N,i) for i in range(30)]
bunbo_list=dict()

def dp(cur,init,seq,lest,num):
    #print(cur,init,seq,lest,num)
    if cur==N:
        if lest==0:
            cnt=sorted(list(Counter(seq).values())+[N-len(seq)],reverse=True)
            bunbo=product(map(factorial,cnt[1:]))
            if bunbo not in bunbo_list.keys():
                bunbo_list[bunbo]=inv_n(bunbo)
            memo[num]=(memo[num]+nPr_list[N-cnt[0]]*bunbo_list[bunbo])%mod
    elif lest==0:
        dp(N,init,seq,0,num)
    else:
        if cur==0:
            for i in range(1,lest+1):
                dp(cur+1,init,seq+[i],lest-i,num)
        else:
            for i in range(1,min(lest,seq[-1])+1):
                dp(cur+1,init,seq+[i],lest-i,num)
 
p=list(Counter(soinsuu(M)).values())
memo=[0]*len(p)


for i in range(len(p)):
    dp(0,p[i],[],p[i],i)
print(product(memo))
### BUGGY CODE ###

x,y,a,b,c = map(int, input().split())
result=sorted(list(map(int, input().split())), reverse=True)[:x]
result+=sorted(list(map(int, input().split())), reverse=True)[:y]
r=sorted(list(map(int, input().split())), reverse=True)
for el in r:
    temp = min(result)
    if el > temp:
        result.remove(temp)
        result.append(el)
print(sum(result))


### FIXED CODE ###

x, y, a, b, c = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse=True)
q = sorted(list(map(int, input().split())), reverse=True)
r = sorted(list(map(int, input().split())), reverse=True)
result = p[:x] + q[:y] + r
result = sorted(result, reverse=True)
print(sum(result[:x+y]))
### BUGGY CODE ###


L, R = map(int, input().split())

mini = (L * R) % 2019
for i in range(L, R + 1):
    for j in range(i + 1, R + 1):
        if(mini > (i * j) % 2019):
            mini = (i * j) % 2019


print(mini)

### FIXED CODE ###


L, R = map(int, input().split())

mini = (L * R) % 2019

if R - L >= 2019:
    print(0)
    exit()

for i in range(L % 2019, R % 2019):
    for j in range(i + 1, R % 2019 + 1):
        mini = min(mini, (i * j) % 2019)



print(mini)
### BUGGY CODE ###

N = int(input())
lst = []
for i in range(N):
    S = str(input())
    if S not in lst:
        lst.append(S)

print(len(lst))

### FIXED CODE ###

N = int(input())
lst = {}
for i in range(N):
    S = str(input())
    if S not in lst.keys():
        lst[S] = []

print(len(lst))
### BUGGY CODE ###

S=input()
N=len(S)
if N<4:
  print(0)
  exit(0)
M=2019
ans=0
for l in range(N-3):
  for r in range(l+3,N):
    if int(S[l:r+1])%M==0:
      ans+=1
print(ans)

### FIXED CODE ###

from collections import defaultdict
d = defaultdict(int)
S=input()
S=S[::-1]
i=1
x=0
MOD=2019
for s in S:
  x+=(int(s)*i)%MOD
  x%=MOD
  d[x]+=1
  i*=10
  i%=MOD
ans=0
for k in d.values():
  ans=ans+k*(k-1)//2
print(ans+d[0])
### BUGGY CODE ###

n,k=map(int,input().split())
if n==0 or k==0:
    print(0)
    exit()

if n%k==0:
    print(0)
    exit()
    
while n > abs(n-k):
    n=abs(n-k)
print(n)

### FIXED CODE ###

n,k=map(int,input().split())
amari=n%k
if n==0:
    print(0)
    exit()

elif n%k==0:
    print(0)
    exit()


else:
    print(min(amari,k-amari))

'''    
while n > abs(n-k):
    n=abs(n-k)
print(n)
'''
### BUGGY CODE ###

S=input()
count=[0 for i in range(2019)]
_S=S[::-1]
_S=_S+'0'
base=1
S=0
for i,s in enumerate(_S):
    S+=base*int(s)
    mod=(S%base)%2019
    count[mod]+=1
    base*=10



retval=0
for key in range(2019):
    retval+=count[key]*(count[key]-1)//2


print(retval)


### FIXED CODE ###

from functools import lru_cache



S=input()
count=[0 for i in range(2019)]
length=len(S)
#S=int(S)
S=S+'0'
S=S[::-1]
_S=0

base=1
for i,s in enumerate(S):
    _S=base*int(s)+_S
    count[_S%2019]+=1
    base*=10
    base=base%2019
    _S=_S%2019



retval=0
for key in range(2019):
    retval+=count[key]*(count[key]-1)//2


print(retval)
### BUGGY CODE ###

x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
l = []
for i in a:
    for j in b:
        l.append(i + j)
c.sort(reverse=True)
l.sort(reverse=True)
l2 = []
for i in c:
    for j in l:
        l2.append(i + j)
l2.sort(reverse=True)
print(*l2[:k], sep="\n")

### FIXED CODE ###

x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
l = []
for i in a:
    for j in b:
        l.append(i + j)
c.sort(reverse=True)
l.sort(reverse=True)
l = l[:k]
l2 = []
for i in c:
    for j in l:
        l2.append(i + j)
l2.sort(reverse=True)
print(*l2[:k], sep="\n")
### BUGGY CODE ###

def main():
    n, k = map(int, input().split())
    aa = sorted(list(map(int, input().split())))
    f = sorted(list(map(int, input().split())), reverse=True)

    a=0
    b=10**12+10
    while a+1 < b:
        med = (a+b)//2
        cnt = 0
        for i in range(n):
            cnt += max(aa[i]-med//f[i], 0)
        if cnt > k:
            a = med+1
        else:
            b = med
    if a == b:
        print(a)
    else:
        cnt = 0
        for i in range(n):
            cnt += max(aa[i]-a//f[i], 0)
        if cnt > k:
            print(b)
        else:
            print(a)


main()

### FIXED CODE ###

def main():
    n,k=map(int,input().split())
    a=sorted(list(map(int,input().split())))
    f=sorted(list(map(int,input().split())),reverse=True)
    def b_search(a,b,value,lim):
        med=(a+b)//2
        if a==b:return a
        elif lim=="upper":
            if a+1==b:
                if value(b):return b
                else:return a
            elif value(med):return b_search(med,b,value,lim)
            else:return b_search(a,med-1,value,lim)
        else:
            if a+1==b:
                if value(a):return a
                else:return b
            elif value(med):return b_search(a,med,value,lim)
            else:return b_search(med+1,b,value,lim)

    def count(val):
        cnt=0
        for i in range(n):
            cnt+=max(a[i]-val//f[i],0)
        if cnt>k:
            return False
        else:
            return True
    
    print(b_search(0,10**12+10,count,"lower"))
    
main()
### BUGGY CODE ###

n=int(input())
al=list(map(int,input().split()))
sa=set(al)
ans=0
for a in sa:
    ans=max(ans,al.count(a)+al.count(a+1)+al.count(a-1))
print(ans)

### FIXED CODE ###

import bisect
n=int(input())
al=list(map(int,input().split()))
al.sort()
sa=set(al)
ans=0
for a in sa:
    ans=max(ans,bisect.bisect_right(al,a+1)-bisect.bisect_left(al,a-1))
print(ans)
### BUGGY CODE ###

import sys
from math import factorial
n, m, k = map(int, input().split())
prime_mod = 998244353

def prime_cycle_division(a, b):
  inverted = pow(b, prime_mod-2, prime_mod)
  return (a*inverted)%prime_mod

def prime_factorial(lower, upper):
  total = 1
  for i in range(lower+1, upper+1):
    total = (total*i)%prime_mod
  return total

def mod_comb(places, objects):
  objects = min(objects, places-objects)
  numerator = prime_factorial(places-objects, places)
  denominator = prime_factorial(0, objects)
  ans = prime_cycle_division(numerator, denominator)
  return ans

def combos(j):
  ans = (m*mod_comb(n-1, j))%prime_mod
  ans = (ans*pow(m-1, n-1-j, prime_mod))%prime_mod
  return ans

total = 0
for j in range(k+1):
  total = (total + combos(j))%prime_mod
print(total)

### FIXED CODE ###

import sys
n, m, k = map(int, input().split())
prime_mod = 998244353

def prime_cycle_division(a, b):
  inverted = pow(b, prime_mod-2, prime_mod)
  return (a*inverted)%prime_mod

def gen_mod_combs(places):
  k = 0
  x = 1
  while True:
    yield x
    factor = prime_cycle_division(places-k, k+1)
    x = (x*factor)%prime_mod
    k += 1

def combos(j):
  ans = (m*next(gen))%prime_mod
  ans = (ans*pow(m-1, n-1-j, prime_mod))%prime_mod
  return ans

total = 0
gen = gen_mod_combs(n-1)
for j in range(k+1):
  total = (total + combos(j))%prime_mod
print(total)
### BUGGY CODE ###

#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush,heapify
from bisect import bisect_left

def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()
    # print(A)
    for i in range(M):
        B, C = map(int, input().split())
        d = bisect_left(A,C)
        # print(B,C,d)
        if d <= B:
            A = [C] * d + A[d:]
        else:
            A = A[B:d] + [C] * B + A[d:]
        # print(A)
    print(sum(A))

if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush,heapify
from bisect import bisect_left

def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()
    q = []
    for i in range(M):
        B, C = map(int, input().split())
        heappush(q,(-C,B))
    
    ans = 0
    index = 0
    # print(A)
    while q:
        c,b = heappop(q)
        c *= -1
        # print(c,b)
        count = 0
        for i in range(b):
            if i + index == N:
                break
            if c > A[index+i]:
                ans += c
                count += 1
            else:
                break

        # print(ans,index)
        if count < b:
            index += count
            break
        else:
            index += count
            
    print(ans + sum(A[index:]))

if __name__ == "__main__":
    main()
### BUGGY CODE ###


import bisect

def solve(N, As):
    colors = []
    for a in As:
        if not colors:
            colors.append(a)
        else:
            if a <= colors[0]:
                colors.insert(0, a)
            else:
                i = bisect.bisect_left(colors, a)
                colors[i - 1] = a
                j = i - 1
                while j + 1 < len(colors) and colors[j] > colors[j + 1]:
                    colors[j], colors[j + 1] = colors[j + 1], colors[j]
                    j += 1
        # print(colors)
    return len(colors)



if __name__ == "__main__":
    N = int(input())
    As = []
    [As.append(int(input())) for i in range(N)]
    print(solve(N, As))


### FIXED CODE ###


import bisect
from array import array


def slow_solve(N, As):
    colors = []
    for a in As:
        if not colors:
            colors.append(a)
        else:
            if a <= colors[0]:
                colors.append(a)
            else:
                i = bisect.bisect_left(colors, a)
                colors[i-1] = a
        colors.sort()
        print(colors)
    return len(colors)


def solve(N, As):
    colors = array('I', [])
    for a in As:
        if not colors:
            colors.append(a)
        else:
            if a <= colors[0]:
                colors.insert(0, a)
            else:
                i = bisect.bisect_left(colors, a)
                colors[i - 1] = a
                j = i - 1
                while j + 1 < len(colors) and colors[j] > colors[j + 1]:
                    colors[j], colors[j + 1] = colors[j + 1], colors[j]
                    j += 1
        # print(colors)
    return len(colors)

#
# for _ in range(100):
#     import random
#     N = 10
#     As = [random.randint(1, 10) for _ in range(5)]
#     if slow_solve(N, As) != solve(N, As):
#         print("OUT")
#         print(N)
#         print(As)
#         input()
# print("OK")

if __name__ == "__main__":
    N = int(input())
    As = []
    [As.append(int(input())) for i in range(N)]
    print(solve(N, As))
### BUGGY CODE ###

n=int(input())
h=list(map(int,input().split()))

ans=0
right_is_max=True

for i in range(n-1,-1,-1):
    if right_is_max==True and i!=n-1:
        if h[i]<h[i+1]:
            right_is_max=False
        else:
            sec+=1
        
    else:    
        for j in range(i,n):
            if j==i:
                tmp=h[j]
                sec=0
            else:
                if tmp<h[j]:
                    break
                else:
                    tmp=h[j]
                    sec+=1
                
    ans=max(ans,sec)
            
print(ans)

### FIXED CODE ###

n=int(input())
h=list(map(int,input().split()))

ans=0

for i in range(n):
    if i==0:
        rightsec=0
    else:
        if h[i-1]>=h[i]:
            rightsec+=1
        else:
            ans=(max(rightsec,ans))
            rightsec=0
            
print(max(ans,rightsec))
### BUGGY CODE ###

a, b = map(int, input().split(' '))
result = 1
for i in range(a, b+1):
	result *= i
print('Positive' if result > 0 else 'Zero' if result == 0 else 'Negative')

### FIXED CODE ###

a, b = map(int, input().split(' '))
result = 'Positive'
if a <= 0 <= b:
	result = 'Zero'
elif b < 0 and (b - a) % 2 == 0:
	result = 'Negative'
print(result)
### BUGGY CODE ###

h,w,m = map(int,input().split())
hw = [list(map(int,input().split())) for _ in range(m)]

gh = {i:[] for i in range(h)}
gw = {i:[] for i in range(w)}

for _h, _w in hw:
    gh[_h-1].append(_w-1)
    gw[_w-1].append(_h-1)
    
ansh = 0
posh = {}
answ = 0
posw = {}
for k,v in gh.items():
    if len(v) > ansh:
        ansh = len(v)
        
for k,v in gh.items():
    if len(v) == ansh:
        posh[k]=k
        
for k,v in gw.items():
    if len(v) > answ:
        answ = len(v)
        
for k,v in gw.items():
    if len(v) == answ:
        posw[k]=k
        
hoge = True
for i in posh:
    for j in posw:
        if i not in gw[j]:
            hoge = False
            
if hoge:
    print(ansh+answ-1)
else:
    print(ansh+answ)

### FIXED CODE ###

h,w,m = map(int,input().split())
hw = [list(map(int,input().split())) for _ in range(m)]

hc = [0]*h
wc = [0]*w
d={}
for _h, _w in hw:
    hc[_h-1]+=1
    wc[_w-1]+=1
    d[(_h-1,_w-1)]=1
    
maxh = max(hc)
maxw = max(wc)
    
        
hoge = True
wi = [i for i in range(w) if wc[i]==maxw]
for h in [i for i in range(h) if hc[i]==maxh]:
    for w in wi:
        if (h,w) not in d:
            hoge=False
            break
            
if hoge:
    print(maxh+maxw-1)
else:
    print(maxh+maxw)
### BUGGY CODE ###

def cmb(n, k, mod):
    numerator = 1
    for i in range(k):
        numerator = (numerator * (n-i)) % mod

    denominator = 1
    for i in range(1, k+1):
        denominator = (denominator * i) % mod

    return (numerator * pow(denominator, mod-2, mod)) % mod


def pow_k(x, n):
    """
    O(log n)
    """
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2

    return K * x


n, a, b = map(int, input().split())
mod = 10**9 + 7
print((pow_k(2, n) % mod - cmb(n, a, mod) - cmb(n, b, mod) - 1) % mod)


### FIXED CODE ###

def cmb(n, k, mod):
    numerator = 1
    for i in range(k):
        numerator = (numerator * (n-i)) % mod

    denominator = 1
    for i in range(1, k+1):
        denominator = (denominator * i) % mod

    return (numerator * pow(denominator, mod-2, mod)) % mod


def pow_k(x, n):
    """
    O(log n)
    """
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2

    return K * x


def myPow(x, n, m):
    if(n == 0):
        return 1
    if(n % 2 == 0):
        return myPow(x * x % m, n / 2, m)
    else:
        return x * myPow(x, n - 1, m) % m


n, a, b = map(int, input().split())
mod = 10**9 + 7
print((myPow(2, n, mod) - cmb(n, a, mod) - cmb(n, b, mod) - 1) % mod)
### BUGGY CODE ###

import sys

N, K = map(int, sys.stdin.readline().split())
A = list(map(int, sys.stdin.readline().split()))

dp = [0] + [None] * (N - 1)
for n in range(1, N):
    l = min(n, K)
    dp[n] = min(abs(A[n] - A[n - k]) + dp[n - k] for k in range(1, l + 1))

print(dp[-1])


### FIXED CODE ###

import sys

N, K = map(int, sys.stdin.readline().split())
A = list(map(int, sys.stdin.readline().split()))

dp = [0] + [None] * (N - 1)
for n, a in enumerate(A):
    if n:
        l = max(0, n - K)
        dp[n] = min(abs(a - a2) + d for a2, d in zip(A[l : n], dp[l : n]))

print(dp[-1])
### BUGGY CODE ###

A, B, K = map(int, input().split())
for i in range(A, B+1):
    # print(A+K, B-K, i)
    if i < A+K or B-K < i:
        print(i)

### FIXED CODE ###

A, B, K = map(int, input().split())
if A+K <= B-K:
    for i in range(A, A+K):
        print(i)
        # print(A+K, B-K, i)
    for i in range(B-K+1, B+1):
        print(i)
else:
    for i in range(A, B+1):
        print(i)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(1000000)

h, w = map(int, input().split())
maze = [list(input()) for i in range(h)]
flag = 0
    
def dfs(x, y, cnt):
    global flag
    if x == w - 1 and y == h - 1:
        flag = 1
        return 
    
    dx = [1, 0]
    dy = [0, 1]

    for i in range(2):
        nx = x + dx[i]
        ny = y + dy[i]
        
        
        if 0 <= nx <= w - 1 and 0 <= ny <= h - 1:
            if maze[ny][nx] == ".":
                dfs(nx, ny, cnt)
            elif maze[ny][nx] == "#" and cnt > 0:
                dfs(nx, ny, cnt - 1)

ans = 0

while ans < h * w:
    dfs(0, 0, ans)
    if flag == 1:
        break
    ans += 1
    
if maze[0][0] == "#":
    ans += 1
    
print(ans)

### FIXED CODE ###

h, w = map(int, input().split())
maze = [list(input()) for i in range(h)]

dp = [[0] * w for i in range(h)]

if maze[0][0] == "#":
    dp[0][0] = 1
    
for i in range(h):
    for j in range(w):
        if i == j == 0:
            continue
                
        if i == 0:
            if maze[0][j] != maze[0][j - 1]:
                dp[0][j] = dp[0][j - 1] + 1
            else:
                dp[0][j] = dp[0][j - 1]
        
        if j == 0:
            if maze[i][0] != maze[i - 1][0]:
                dp[i][0] = dp[i - 1][0] + 1
            else:
                dp[i][0] = dp[i - 1][0]
        
        if i != 0 and j != 0:
            tmp1 = 0
            tmp2 = 0
            if maze[i][j] != maze[i - 1][j]:
                tmp1 = 1
            if maze[i][j] != maze[i][j - 1]:
                tmp2 = 1
        
            dp[i][j] = min(dp[i - 1][j] + tmp1, dp[i][j - 1] + tmp2)

if maze[h - 1][w - 1] == "#":
    dp[h - 1][w - 1] += 1

ans = dp[h - 1][w - 1] // 2

print(ans)
### BUGGY CODE ###

n, w = map(int,input().split())
wv = [tuple(map(int, input().split())) for _ in range(n)]
dp = [[0] * (w+1) for _ in range(n+1)]

for i in range(1, n+1):
    for j in range(1, w+1):
        if wv[i-1][0] <= j:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-wv[i-1][0]] + wv[i-1][1])
        else:
            dp[i][j] = dp[i-1][j]
print(dp[n][w])

### FIXED CODE ###

n, w = map(int,input().split())
wv = [tuple(map(int, input().split())) for _ in range(n)]
dp = [[0] * (w+1) for _ in range(n+1)]

for i in range(1, n+1):
    for j in range(1, w+1):
        if wv[i-1][0] <= j:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-wv[i-1][0]] + wv[i-1][1])
        else:
            dp[i][j] = dp[i-1][j]
print(dp[n][w])
### BUGGY CODE ###

def main():
  n=int(input())
  a=list(map(int,input().split()))
  ap=[i+1 for i in set(a)]
  am=[i-1 for i in set(a)]
  A=set(ap+am+a)
  count=0
  for i in A:
    x=0
    for j in a:
      x+=1 if i==j or i==j+1 or i==j-1 else 0
    count=max(count,x)
  print(count)
if __name__=='__main__':
  main()

### FIXED CODE ###

def main():
  n=input()
  a=tuple(map(int,input().split()))
  cnt=[0]*(pow(10,5)+2)
  for i in a:
    cnt[i-1]+=1
    cnt[i]+=1
    cnt[i+1]+=1
  print(max(set(cnt)))   
if __name__=='__main__':
  main()