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

station_num = int(input())
station_list = [[0, 0, 0] for i in range(station_num)]

for i in range(station_num - 1):
    station_list[i] = input().split()
# print(station_list)

for i in range(station_num):
    count = int(station_list[i][0]) + int(station_list[i][1])
    now_position = i + 1
    while True:
        if now_position == station_num - 1 or now_position == station_num:
            print(count)
            break
        else:
            while True:
                if count < int(station_list[now_position][1]):
                    count = int(station_list[now_position][1])
                elif count % int(station_list[now_position][2]) == 0:
                    count += int(station_list[now_position][0])
                    now_position += 1
                    break
                else:
                    count += 1

### FIXED CODE ###

station_num = int(input())

if station_num == 1:
    print(0)
else:
    station_list = [[0, 0, 0] for i in range(station_num)]
    
    for i in range(station_num - 1):
        station_list[i] = input().split()
    # print(station_list)
    
    for i in range(station_num):
        count = int(station_list[i][0]) + int(station_list[i][1])
        now_position = i + 1
        while True:
            if now_position == station_num - 1 or now_position == station_num:
                print(count)
                break
            else:
                while True:
                    if count < int(station_list[now_position][1]):
                        count = int(station_list[now_position][1])
                    elif count % int(station_list[now_position][2]) == 0:
                        count += int(station_list[now_position][0])
                        now_position += 1
                        break
                    else:
                        count = count + int(station_list[now_position][2]) - (count % int(station_list[now_position][2]))
### BUGGY CODE ###

import bisect
from collections import deque
n=int(input())
a=[int(input()) for _ in range(n)]

q=deque()

for sa in a:
    lq = list(q)
    t = bisect.bisect_left(lq,sa)
    if t ==0:
        q.appendleft(sa)
    else:
        q[t-1] = sa

print(len(q))

### FIXED CODE ###

import bisect
from collections import deque
n=int(input())
a=[int(input()) for _ in range(n)]

q=[]
def bisect_desc(a,x):
    r = len(a)
    if r == 0:
        return 0
    l = 0
    while l != r:
        f = (l+r)//2
        if a[f] >= x:
            l = f+1
        else:
            r = f
    return l

for sa in a:
    t = bisect_desc(q,sa)
    if t ==len(q):
        q.append(sa)
    else:
        q[t] = sa

print(len(q))
### BUGGY CODE ###

count = 0
def check(xs):
    return list(map(lambda x: int(x / 2), xs))

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

while len(set(list(map(lambda x: x % 2, s)))) == 1:
    s = check(s)
    count += 1
print(count)

### FIXED CODE ###

input()
s=list(map(int,input().split()))
bl = 0
for i in s:
  bl |= i
print(len(bin(bl&-bl))-3)
### BUGGY CODE ###

N = int(input())
S = input()
ans = S.count("R") * S.count("G") * S.count("B")

for i in range(N - 2):
    for j in range(i + 1, N - 1):
        if S[i] != S[j]:
            x = j + j - i
            if x <= N - 1 and S[i] != S[x] and S[x] != S[j]:
                ans -= 1

print(ans)


### FIXED CODE ###

N = int(input())
S = input()
ans = S.count("R") * S.count("G") * S.count("B")

for i in range(N - 2):
    for j in range(i + 1, N - 1):
        if S[i] != S[j]:
            x = 2 * j - i
            if x < N and S[i] != S[x] and S[x] != S[j]:
                ans -= 1

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

#!/usr/bin/python3
# -*- coding: utf-8 -*-
def euclid(a, b):
    if b == 0:
        return a
    else:
        return euclid(b, a%b)
def list_euclid(int_list):
    ans = int_list[0]
    for i in range(1,len(int_list)):
        ans = euclid(ans, int_list[i])
    return ans

n = int(input())
a = list(map(int, input().split()))
max = 0
for i in range(0,n):
    new_list = a[:]
    del new_list[i]
    x = list_euclid(new_list)
    if max < x:
        max = x
print(max)

### FIXED CODE ###

#!/usr/bin/python3
# -*- coding: utf-8 -*-
import sys
def gcd(a, b): #最大公約数
  while b:
    a, b = b, a % b
  return int(a)
    
n = int(input())
a = list(map(int, input().split()))
if n==2:
  print(max(a))
  sys.exit(0)
elif n==3:
  lis = [gcd(a[0], a[1]), gcd(a[1], a[2]), gcd(a[2], a[0])]
  print(max(lis))
  sys.exit(0)
tmp_unused = gcd(a[0], a[1])
tmp_used = max(a[0], a[1])
#print("used=", tmp_used, "unused=", tmp_unused)
for i in range(2,n):
  #print(a[i])
  tmp_used = max(tmp_unused, gcd(tmp_used, a[i]))
  tmp_unused = gcd(tmp_unused, a[i])
  
  #print("used=", tmp_used, "unused=", tmp_unused)
print(tmp_used)
### BUGGY CODE ###

N = int(input())

Ninzu = []
for x in input().split():
	Ninzu.append(int(x))

i = 1
for i in range(0,N):
	print(Ninzu.count(i+1))

### FIXED CODE ###

import collections

N = int(input())

Ninzu = []
for x in input().split():
	Ninzu.append(int(x))

l = collections.Counter(Ninzu)

for i in range(1,N):
	print(l[i])

print(0)
### BUGGY CODE ###

N,K = map(int,input().split())
h = list(map(int,input().split()))

costs = [0] * N
costs[1] = abs(h[1]-h[0])
for i in range(2,N):
  s = max(i-K,0)
  mn = float('inf')
  for a,b in zip(costs[s:i],h[s:i]):
    cur = a + abs(h[i]-b)
    if cur < mn:
      mn = cur
 
  costs[i] = mn
print(costs[-1])

### FIXED CODE ###

N,K = map(int,input().split())
h = list(map(int,input().split()))

def aa (n,k,ll):
  dp = [0] * n
  for i in range(1,n):
    s = max(i-k,0)
    mn = float('inf')
    for a,b in zip(dp[s:i],ll[s:i]):
      cur = a + abs(ll[i]-b)
      if cur < mn:
        mn = cur
  
    dp[i] = mn
  print(dp[-1])

aa(N,K,h)
### BUGGY CODE ###

N, K = map(int, input().split())
Nj = N
if (K == 1) or (N==K):
    print(0)
while (Nj == K) is False:
    Ni = Nj
    Nj = abs(Ni - K)
    if Nj == K:
        print(0)
        break
    elif Nj > Ni:
        print(Ni)
        break
    else:
        continue

### FIXED CODE ###

n,k = map(int,input().split())
if n % k ==0:
    print(0)
else:
    l = [n]
    p = n//k
    c = n-(p*k)
    half = k//2
    while c > half:
        c = abs(c-k)
    l.append(c)
    print(min(l))
### BUGGY CODE ###

n=int(input())

battle=[]

def mainasu(x):
    return int(x)-1
front=[]

for _ in range(n):
    tmp=list(map(mainasu,input().split()))[::-1]
    front.append(tmp.pop())
    battle.append(tmp)

day=0

#pri()
cnt=0
while 1:
    flag=0
    for i in range(n):
        if front[i]<n and i==front[front[i]]:
            flag=1
            front[front[i]]=n
            front[i]=n

    if flag==0:
        break

    cnt=0
    for i in range(n):
        if front[i]==n:
            if len(battle[i])>0:
                front[i]=battle[i].pop()
            else:
                cnt+=1
    day+=1
    

if cnt==n:
    print(day)
else:
    print(-1)            

    




### FIXED CODE ###

n=int(input())

battle=[]

def mainasu(x):
    return int(x)-1

front=[]

for _ in range(n):
    tmp=list(map(mainasu,input().split()))[::-1]
    front.append(tmp.pop())
    battle.append(tmp)

def pri():
    global front,battle,day,checkday
    print(day,front,battle,checkday)

day=0

checkday=[-1]*n

#pri()
cnt=0
while 1:
    flag=0
    for i in range(n):
        if i<n and front[i]<n and i==front[front[i]] and checkday[i]<day and checkday[front[i]]<day:
            flag=1
            if len(battle[front[i]])>0:
                front[front[i]]=battle[front[i]].pop()
                checkday[front[i]]=day
            else:
                front[front[i]]=n
                cnt+=1
            
            if len(battle[i])>0:
                front[i]=battle[i].pop()
                checkday[i]=day
            else:
                front[i]=n
                cnt+=1
    #pri()
    if flag==0:
        break
    
    day+=1


if cnt==n:
    print(day)
else:
    print(-1)
### BUGGY CODE ###

import math
a,b=map(int,input().split())
gcd=math.gcd(a,b)

def prime_factorization(n):
  i=2
  prime=[]
  while i*i<=n or n>1:
    if n%i:
      i+=1
    else:
      n//=i
      prime.append(i)
      while n%i==0:
        n//=i
  if n>1:
    prime.append(n)
  return prime

print(len(prime_factorization(gcd))+1)

### FIXED CODE ###

a,b=map(int,input().split())

def prime_factorization(n):
  if n==1:
    return [1]
  else:
    i=2
    ans=[]
    k=int(n**0.5)+1
    for j in range(2,k+1):
      if n==1: break
      if n%j==0:
        n//=j
        ans.append(j)
        while n%j==0:
          n//=j
    if len(ans):
      ans.append(1)
      if n!=1:
        ans.append(n)
      return ans
    else:
      return [1,n]

A=prime_factorization(a)
B=prime_factorization(b)
#print(A)
#print(B)

print(len(set(A)&set(B)))
### BUGGY CODE ###

a, b, n = map(int, input().split())
ans = 0
s = int(b/a)
e = min(n+1,b)
for i in range(s, e):
  x = (int(a*i/b)-a*int(i/b))
  if ans < x:
    ans = x
print(ans)

### FIXED CODE ###

a, b, n = map(int, input().split())
ans = 0
e = min(n+1,b)
s = max(int(b/a),e-1000)
for i in range(s, e):
  x = (int(a*i/b)-a*int(i/b))
  if ans < x:
    ans = x
print(ans)
### BUGGY CODE ###

import sys
import itertools
import queue
input = sys.stdin.readline
sys.setrecursionlimit(100000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if self.v is None:
            self.v = n
        else:
            self.v = self.f(self.v, n) 


def main():
    N, X, Y = read_values()
    X -= 1
    Y -= 1
    res = [0] * N

    for i in range(N):
        q = queue.Queue()
        q.put((i, 0))
        close = set()
        while not q.empty():
            s, c = q.get()
            if s in close:
                continue
            
            close.add(s)
            res[c] += 1

            if s + 1 < N and s + 1 not in close:
                q.put((s + 1, c + 1))
            if s > 0 and s - 1 not in close:
                q.put((s - 1, c + 1))
            if s == X and Y not in close:
                q.put((Y, c + 1))
            if s == Y and X not in close:
                q.put((X, c + 1))

    res = map(lambda l: str(l // 2), res[1:])
    print("\n".join(res))


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
import itertools
import queue
input = sys.stdin.readline
sys.setrecursionlimit(100000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if self.v is None:
            self.v = n
        else:
            self.v = self.f(self.v, n) 


def main():
    N, X, Y = read_values()
    X -= 1
    Y -= 1
    res = [0] * N

    for i in range(N - 1):
        for j in range(i + 1, N):
            d = min(
                j - i,
                abs(X - i) + 1 + abs(Y - j),
                abs(Y - i) + 1 + abs(X - j),
            )

            res[d] += 1

    for r in res[1:]:
        print(r)


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

import math
import numpy as np
from fractions import gcd
import fractions
import statistics
import collections
from functools import reduce
import itertools
from collections import defaultdict
import bisect
from fractions import Fraction
 
 
N = int(input())
A=list(map(int, input().split()))
 
num = A[0]
for i in range(1, N):
    num = num * A[i] // fractions.gcd(num, A[i])
 
ans = 0
 
for i in range(N):
    ans += (num // A[i])
 
print(ans%(10**9+7))

### FIXED CODE ###

import fractions as math
from functools import reduce
 
 
N = int(input())
A=list(map(int, input().split()))
 
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
 
num = lcm_list(A)
 
ans = 0
 
for i in range(N):
    ans += (num // A[i])
 
print(ans%(10**9+7))
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()

cnt = 0
tmp = N
while tmp != 0:
  cnt += 1
  tmp //= 2

def binary_search(v, L):
  if max(L) <= v:
    return 0
  elif min(L) > v:
    return N
  else:
    l, r = 0, N
    d = (l + r) // 2
    for _ in range(cnt+2):
      if L[d] <= v:
        l = d + 1
        d = (l + r) // 2
      else:
        r = d
        d = (l + r) // 2
    return N - d

LB = [binary_search(B[_], C) for _ in range(N)]
for i in range(N-1, 0, -1):
  LB[i-1] += LB[i]
S = 0
for i in range(N):
  X = N - binary_search(A[i], B)
  if X == N:
    break
  else:
    S += LB[X]
print(S)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
B.sort()
C.sort()

cnt = 0
tmp = N
while tmp != 0:
  cnt += 1
  tmp //= 2

def binary_search(v, L, M, m):
  if M <= v:
    return 0
  elif m > v:
    return N
  else:
    l, r = 0, N
    d = (l + r) // 2
    for _ in range(cnt):
      if L[d] <= v:
        l = d + 1
        d = (l + r) // 2
      else:
        r = d
        d = (l + r) // 2
    return N - d
MB, mB, MC, mC = B[N-1], B[0], C[N-1], C[0]
LB = [binary_search(B[_], C, MC, mC) for _ in range(N)]
for i in range(N-1, 0, -1):
  LB[i-1] += LB[i]
S = 0
for i in range(N):
  X = N - binary_search(A[i], B, MB, mB)
  if X != N:
    S += LB[X]
print(S)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

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()))

ab = sorted(x+y for x in a for y in b)[:-k-1:-1]
abc = sorted(ab+z for ab in ab[:k] for z in c)[:-k-1:-1]

print(*abc, sep="\n")




### FIXED CODE ###

import sys
input = sys.stdin.readline

x,y,z,k = map(int,input().split())
lisa = sorted(map(int,input().split()))
lisb = sorted(map(int,input().split()))
lisc = sorted(map(int,input().split()))

ab = sorted(a+b for a in lisa for b in lisb)[:-k-1:-1]
abc = sorted(ab+c for ab in ab[:k] for c in lisc)[:-k-1:-1]

print(*abc, sep="\n")
### BUGGY CODE ###

import math
a=int(input())
b=list(i+1 for i in range(a))
www=0
for j in b:
  ans=0
  c=[x+1 for x in range(int(math.sqrt(j)//1))]
  for y in c:
    if j%y==0:
      if not j/y==y:
        ans+=2
      else:
        ans+=1
  www+=ans*j
print(www)

### FIXED CODE ###

a=int(input())
b=(a)//2+1
ans=0
for i in range(1,b,1):
  x=a//i
  ans+=((x**2+x)//2)*i
ans+=(a**2+a+b-b**2)//2
print(ans)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
R = [0] * (N + 1)
P = [1] * (N + 1)
mod = 10 ** 9 + 7

def power(x, y):
    if y == 0:
        return 1
    elif y == 1: 
        return x % mod
    elif y % 2 == 0: 
        return power(x, y//2)**2 % mod
    else: 
        return power(x, y//2)**2 * x % mod

def rev(a):
    return power(a, mod - 2)
    
for n in range(N + 1):
    R[n] = R[n - 1] + rev(n)
    if n != 0:
        P[n] = P[n - 1] * n

res = 0
for i in range(N):
    res += ((R[i + 1] + R[N - i] - 1) * A[i] * P[N]) % mod

print(res % mod)


### FIXED CODE ###

import numpy as np
N = int(input())
A = list(map(int, input().split()))
R = np.zeros(N + 1, dtype="int64")
P = np.ones(N + 1, dtype="int64")
mod = 10 ** 9 + 7

def rev(a):
    return pow(a, mod - 2, mod)
    
for n in range(N + 1):
    r = rev(n)
    R[n] = (R[n - 1] + r) % mod
    if n != 0:
        P[n] = (P[n - 1] * n) % mod

C = [(R[j] + R[N - j + 1] - 1) % mod for j in range(1, N + 1)]

res = 0
for i in range(N):
    res = (res + (A[i] * C[i]) % mod) % mod

print(res * P[N] % mod)
#print((sum([a * c % mod for a, c in zip(C, A)]) * P[N]) % mod)
### BUGGY CODE ###

from itertools import product
def main():
    H, W = list(map(int, input().split()))
    A = [['#'] * (W + 2)] + [['#', ] + list(input()) + ['#', ] for _ in range(H)] + [['#'] * (W + 2)]
    DX = [[1, 0], [-1, 0], [0, 1], [0, -1]]
    ans = 0
    for h, w in product(range(1, H + 1), range(1, W + 1)):
        if A[h][w] == '.':
            count = 1
            for (dx, dy) in DX:
                x, y = h, w
                while True:
                    if A[x + dx][y + dy] == '.':
                        x += dx
                        y += dy
                        count += 1
                    else:
                        break
            ans = max(ans, count)
        else:
            continue
    print(ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import numpy as np
def main():
    printl = lambda l: [print(x) for x in l]
    H, W = list(map(int, input().split()))
    A = np.array([[1 if i == '.' else 0 for i in input()] for _ in range(H)])
    L = np.zeros((H, W), dtype = np.int)
    R = np.zeros((H, W), dtype = np.int)
    U = np.zeros((H, W), dtype = np.int)
    D = np.zeros((H, W), dtype = np.int)
    L[:, 0] = A[:, 0]
    for w in range(1, W):
        L[:, w] = (L[:, w - 1] + 1) * A[:, w]
    R[:, W - 1] = A[:, W - 1]
    for w in range(W - 2, -1, -1):
        R[:, w] = (R[:, w + 1] + 1) * A[:, w]
    U[0, :] = A[0, :]
    for h in range(1, H):
        U[h, :] = (U[h - 1, :] + 1) * A[h, :]
    D[H - 1, :] = A[H - 1, :]
    for h in range(H - 2, -1, -1):
        D[h, :] = (D[h + 1, :] + 1) * A[h, :]
    print(np.max(L + R + U + D - 3))

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

def main():
    s = input()
    q = int(input())
    is_fwd = True
    for i in range(q):
        fields = [i for i in input().split()]
        t = int(fields[0])
        if t == 1:
            is_fwd = not is_fwd
        elif t == 2:
            f = int(fields[1])
            c = fields[2]
            if (f == 1) == is_fwd:
                s = c + s
            else:
                s += c

    if is_fwd:
        print(s)
    else:
        print(s[::-1])

main()


### FIXED CODE ###

def main():
    s = input()
    q = int(input())
    is_fwd = True
    before = ''
    after = ''

    for i in range(q):
        fields = [i for i in input().split()]
        t = int(fields[0])
        if t == 1:
            is_fwd = not is_fwd
        elif t == 2:
            f = int(fields[1])
            c = fields[2]
            if (f == 1) == is_fwd:
                before += c
            else:
                after += c

    res = before[::-1] + s + after
    if is_fwd:
        print(res)
    else:
        print(res[::-1])

main()
### BUGGY CODE ###

import sys
n ,k = map(int, input().split())
 
 
if n == k or k == 1:
    print(0)
    sys.exit()
    
while True:
    b = abs(n-k)
    if b == 0:
        print(0)
        sys.exit()
    elif b == 1:
        print(1)
        sys.exit()
    elif n < b:
        print(n)
        sys.exit()
    n = b

### FIXED CODE ###

import sys
n ,k = map(int, input().split())
if n == k or k == 1:
    print(0)
    sys.exit()
else:
    n %= k
print(min(n, abs(n-k)))
### BUGGY CODE ###

n = int(input())
ans = 0
for a in range (1,n):
  for b in range (1,n):
    if n > (a * b):
        ans += 1
print(ans)

### FIXED CODE ###

n = int(input())
ans = 0
for a in range (1,n):
    for b in range(a, n, a):
        ans += 1
print(ans)
### BUGGY CODE ###

N,M = map(int, input().split())
A = list(map(int,input().split()))
A.sort()
max = 0 

for i in range(M):
    B,C = map(int, input().split())
    for j in range(B) :
        if  C > A[j] : 
            A[j] = C
    A.sort()
sum = 0 
for i in range(N):
    sum += A[i] 

print(sum)

### FIXED CODE ###

import collections
N,M = map(int, input().split())
A = list(map(int,input().split()))
D = collections.Counter(A)

A.sort()
max = 0 

for i in range(M):
    B,C = map(int, input().split())
    D[C] += B  

D = sorted(D.items(), key=lambda x:x[0],reverse=True)

sum = 0 
count = 0 
for k,v in D:
    if N > v : 
        sum += k * v
        N -= v 
    else : 
        sum += k * N 
        break 
print(sum)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 6)
def input():
    return sys.stdin.readline()[:-1]

def dfs(v,prev = -1):
    for u in graph[v]:
        if u == prev:
            continue
        point[u] += point[v]
        dfs(u,v)

N, Q = list(map(int,input().split()))
graph = [[] for _ in range(N)]
point = [0]*N

for i in range(N-1):
    a,b = list(map(int,input().split()))
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

for i in range(Q):
    p,x = list(map(int,input().split()))
    p -= 1
    point[p] += x

dfs(0)
print(*point)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 6)
import sys
def input():
    return sys.stdin.readline()[:-1]
N , Q = map(int,input().split())
graph = [[] for _ in range(N)]
point = [0] * N
for _ in range(N - 1):
    a , b = map(int,input().split())
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)
#print(graph)
for _ in range(Q):
    a , b = map(int,input().split())
    a = a - 1
    point[a] += b
# dfsを用いて累積和を計算する
# 初期状態だと前の値がないためデフォルト引数に-1を代入
def dfs(now , prev = -1):
    for next in graph[now]:
        # 次のノードが前に参照した値の時はcontinue
        if next == prev:
            continue
        # 現在の値を次のポイントに加算することで累積和をとる
        point[next] += point[now]
        # 次のノードと現在のノードを引数にdfsを継続する
        dfs(next , now)

dfs(0)
print(*point)
### BUGGY CODE ###

# coding: utf-8
import sys
import collections

N = int(sys.stdin.readline())

monster = [int(a) for a in sys.stdin.readline().strip().split()]
monster.sort()

while len(monster)>1:
    monster[1] %= monster[0]
    if monster[1] == 0:
        monster.pop(1)
    monster.sort()


print(monster[0])

### FIXED CODE ###

# coding: utf-8
import sys
import collections

N = int(sys.stdin.readline())

monster = [int(a) for a in sys.stdin.readline().strip().split()]
monster.sort()

while len(monster)>1:
    for i in range(1,len(monster)):
        monster[i] %= monster[0]
    monster.sort()
    while monster[0]==0:
        monster.pop(0)
    


print(monster[0])
### BUGGY CODE ###

import math
def nCr(n,r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))

h,w,a,b=map(int,input().split())
amari = 10**9+7

#1.境界まで行く順路のパターン数を求める
l1 = [0 for i in range(w-b)]
for i in range(len(l1)):
    l1[i]=nCr((h-a-1)+b+i,b+i)
#2.境界の1コ下からゴールまで行く順路のパターン数を求める
l2 = [0 for i in range(w-b)]
for i in range(len(l2)):
    l2[i]=nCr((a-1)+(w-b-i-1),a-1)

out= 0 
for i,j in zip(l1,l2):
    #print(i*j)
    out += i*j

print(out%amari)

### FIXED CODE ###

h,w,a,b =map(int,input().split())
mod = 10**9+7

#階乗を求める
fact_l = [1 for i in range(h+w+1)]
for i in range(1,len(fact_l)):
    fact_l[i] *= (fact_l[i-1]*i)%mod

#逆元
factinv_l = [1 for i in range(h+w+1)]
for i in range(1,len(fact_l)):
    factinv_l[i] = pow(fact_l[i],mod-2,mod)
    
#必ず通るポイントまでの組み合わせ
point1 = [1 for i in range(w-b)]
for i in  range(len(point1)):
    yoko = b+i 
    tate = h-a-1
    n = yoko+tate
    r = yoko
    point1[i] = fact_l[n]*factinv_l[r]*factinv_l[n-r]%mod

#point1からの経路
out = 0
for i in range(len(point1)):
    yoko = w-b-i-1
    tate = a-1
    n = yoko+tate
    r = yoko
    case = fact_l[n]*factinv_l[r]*factinv_l[n-r]%mod
    out += (point1[i]*case)%mod
print(out%mod)
### BUGGY CODE ###

def resolve():
    n = int(input())
    s = []
    for i in range(n):
        d = input()
        if not (d in s):
            s += [d]
    print(len(s))
resolve()

### FIXED CODE ###

def resolve():
    import sys
    input = lambda: sys.stdin.readline().rstrip()
    r = [0] * int(input())
    print(len({input() for _ in r}))

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

N = int(input())
numbers = [int(i) for i in input().split()]

biggest = 1
for i in range(min(numbers),max(numbers)+1):
    count = numbers.count(i-1) + numbers.count(i) + numbers.count(i+1)
    if biggest <= count:
        biggest = count
print(biggest)    
    

### FIXED CODE ###

import collections
N = int(input())
numbers = [int(i) for i in input().split()]
count = collections.Counter(numbers)
biggest = 1
for i in count:
    counting = count[i-1] + count[i] + count[i+1]
    if  counting > biggest:
        biggest = counting

print(biggest)