Harryxun/stf_run huggingface dataset:
N = int(raw_input())
H = raw_input()
H = H.split()
for i, val in enumerate(H):
    H[i] = int(val)
Top = 0
Bottom = len(H)-1
T_PList = [0, Bottom]
count = max(H)
total = 0
Top_L = []
Bot_L = []
current_top = H[0]
current_bot = H[0]
if N <= 2:
    print(count)
else:
    if H[0] > H[1]:
        Top_L.append(H[0])
        current_bot = H[1]
        current_top = [-1]
    elif H[0] < H[1]:
        current_top = H[1]
        current_bot = -1

    for i in range(2,len(H),1):
        if (current_top == H[i-1]) & (H[i]>H[i-1]):
            current_top = H[i]
        elif (current_top == H[i-1]) & (H[i]<H[i-1]):
            Top_L.append(current_top)
            current_bot = H[i]
            current_top = -1
        elif (current_bot == H[i-1]) & (H[i]<H[i-1]):
            current_bot = H[i+1]
        elif (current_bot == H[i-1]) & (H[i]>H[i-1]):
            Bot_L.append(current_bot)
            current_bot = -1
            current_top = H[i]
        # print(current_top)
        # print(current_bot)
    last = len(H)
    if H[last-1] > H[last-2]:
        Top_L.append(H[last-1])
    print(sum(Top_L)-sum(Bot_L))




### FIXED CODE ###

N = int(input())
H = input()
H = H.split()
for i, val in enumerate(H):
    H[i] = int(val)
maxNum = max(H)
counter = 0
for i in range(maxNum):
    for j, val in enumerate(H):
        if H[j] != 0:
            H[j] -= 1
            if j < (N-1):
                if H[j + 1] == 0:
                    counter += 1
            if j == (N - 1):
                counter += 1
    # print(H)
    # print(counter)
print(counter)
def main():
    MOD = 7 + 10**9
    S = list(input())
    N = len(S)
    dp = [[0]*13 for _ in range(N)]
    if S[N-1] == '?':
        for m in range(10):
            dp[0][m] = 1
    else:
        tm = int(S[N-1])%13
        dp[0][tm] = 1
    for i in range(1,N):
        if S[N-1-i] == '?':
            for j in range(13):
                for k in range(10):
                    dp[i][j] += [dp[i-1][(j-(k*10**i)%13)%13]%MOD
        else:
            m = (int(S[N-1-i])*10**i) % 13
            for l in range(13):
                dp[i][l] += dp[i-1][(l-m)%13]
    print(dp[N-1][5]%MOD)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    MOD = 7 + 10**9
    S = tuple(input())
    N = len(S)
    dp = [[0]*13 for _ in range(N+1)]
    dp[0][0] += 1
    s=[1]
    for n in range(1,N):
        s.append((s[n-1]*10)%13)
    for i in range(N):
        for k in range(13):
            if S[-(i+1)] != '?':
                dp[i+1][(k+int(S[-(i+1)])*s[i])%13] += dp[i][k] 
                dp[i+1][(k+int(S[-(i+1)])*s[i])%13] %= MOD
            else:
                for l in range(10):
                    dp[i+1][(k+l*s[i])%13] += dp[i][k]
                    dp[i+1][(k+l*s[i])%13] %= MOD
    print(dp[-1][5])

if __name__ == '__main__':
    main()
import math

a, b, c= [int(x) for x in input().split()] 

# Atcoder beginner contest 145. A - Circle

r = int(input())

a = (math.pi * (r)**2)
ans = a / math.pi

# the answer must be integer, != float
print(int(ans))

### FIXED CODE ###

import math

r = int(input())

pi = int(math.pi)

a = (pi * (r)**2)
ans = a / pi

print(int(ans))
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy
import numpy as np

class SegmentTree:

    def __init__(self, n, fn=lambda x, y: min(x, y), unity=(1 << 31) - 1):
        self.n = 1
        while self.n < n:
            self.n *= 2

        self.arr = np.full(2 * self.n - 1, unity)
        self.fn = fn
        self.unity = unity

    def update(self, i, x):
        k = self.n + i - 1
        self.arr[k] = x

        while k > 0:
            k = (k - 1) // 2
            self.arr[k] = self.fn(self.arr[2 * k + 1], self.arr[2 * k + 2])

    def query(self, l, r):
        return self._inner_query(l, r, 0, 0, self.n)

    def _inner_query(self, l, r, k, il, ir):
        if ir <= l or r <= il:
            return self.unity

        elif l <= il and ir <= r:
            return self.arr[k]

        vl = self._inner_query(l, r, k * 2 + 1, il, (il + ir) // 2)
        vr = self._inner_query(l, r, k * 2 + 2, (il + ir) // 2, ir)
        return self.fn(vl, vr)

    def __str__(self):
        return self.arr[0: 2 * self.n].__str__()


N, K = map(int, input().split())
MAX = 300000

st = SegmentTree(MAX + 10, fn=lambda x, y: max(x, y), unity=0)
ans = 0

while N > 0:
    A = int(input())
    minimum, maximum = max(A - K, 0), min(A + K, MAX)
    x = st.query(minimum, maximum + 1) + 1
    ans = max(ans, x)
    st.update(A, x)
    N -= 1

print(ans)


### FIXED CODE ###

import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy


def input():
    return sys.stdin.readline()[:-1]


class SegmentTree:

    def __init__(self, n, fn=lambda x, y: min(x, y), unity=(1 << 31) - 1):
        self.n = 1
        while self.n < n:
            self.n *= 2

        self.arr = [unity] * (2 * self.n - 1)
        self.fn = fn
        self.unity = unity

    def update(self, i, x):
        k = self.n + i
        self.arr[k] = x

        while k > 0:
            k >>= 1
            self.arr[k] = self.fn(self.arr[2 * k], self.arr[2 * k + 1])

    def query(self, l, r):
        l += self.n
        r += self.n
        lres, rres = self.unity, self.unity
        while l < r:
            # lが奇数ならば、dat[l]を加算
            if l & 1:
                lres = self.fn(lres, self.arr[l])
                l += 1

            # rが奇数ならば、dat[r-1]を加算
            if r & 1:
                r -= 1
                rres = self.fn(rres, self.arr[r])

            # 木をのぼる
            l >>= 1
            r >>= 1

        return self.fn(lres, rres)




    def __str__(self):
        return self.arr[0: 2 * self.n].__str__()


N, K = map(int, input().split())
MAX = 300000

st = SegmentTree(MAX + 10, fn=lambda x, y: max(x, y), unity=0)
ans = 0

while N > 0:
    A = int(input())
    minimum, maximum = max(A - K, 0), min(A + K, MAX)
    x = st.query(minimum, maximum + 1) + 1
    ans = max(ans, x)
    st.update(A, x)
    N -= 1

print(ans)
a, b = list(map, (int, input().split()))

if a % 2 == 1 or b % 2 == 1:
  print('No')
else:
  print('Yes')

### FIXED CODE ###

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

if a % 2 == 1 and b % 2 == 1:
  print('Yes')
else:
  print('No')
#! /usr/bin/env python3

N, X = map(int, input().split())
if X*2 == N:
    print(X*3)
else:
    print(X*3*((N-X)//X + (1 if (N-X)%X>0 else 0)))

### FIXED CODE ###

#! /usr/bin/env python3

N = int(input())
L = list(sorted(map(int, input().split())))
ans = 0
for i in range(N):
    ans += min(L[i*2], L[i*2+1])
print(ans)
N = int(input())
S = input()

r = 0
b = 0
for si in S:
    if s == 'R':
        r += 1
    else:
        b += 1

if r > b:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

N = int(input())
S = input()

r = 0
b = 0
for si in S:
    if si == 'R':
        r += 1
    else:
        b += 1

if r > b:
    print('Yes')
else:
    print('No')
a, b, c, d = list(map(int, list(input())))

ops = {'+', '-'}

for op1 in ops:
    if op1 == '+': ab = a+b
    else: ab = a-b
    
    for op2 in ops:
        if op2 == '+': abc = ab+c
        else: abc = ab-c
        
        for op3 in ops:
            if op3 == '+': abcd = abc+d
            else: abcd = abc-d

            if abcd == 7:
                print(f'{a}{op1}{b}{op2}{c}{op3}{d}=7')
                exit()

### FIXED CODE ###

a, b, c, d = list(map(int, list(input())))

ops = {'+', '-'}

for op1 in ops:
    if op1 == '+': ab = a+b
    else: ab = a-b
    
    for op2 in ops:
        if op2 == '+': abc = ab+c
        else: abc = ab-c
        
        for op3 in ops:
            if op3 == '+': abcd = abc+d
            else: abcd = abc-d

            if abcd == 7:
                a, b, c, d = map(str, [a, b, c, d])
                print(a+op1+b+op2+c+op3+d+'=7')
                exit()
#整数の入力
N = int(input())
#文字列の入力
S = input()

#listを一文字ずつのlistに
S_list = list(S)

ans = ""
for i in range(len(S_list)):
  if(N+i<=len(S_list)):
    ans = ans + S_list[N+i]
  else:
    ans = ans + S_list[len(S_list)-N-i]
  
print(ans)



### FIXED CODE ###

#整数の入力
N = int(input())
#文字列の入力
S = input()
#listを一文字ずつのlistに
S_list = list(S)

ans = ""
for i in range(len(S_list)):
  if(ord(S_list[i])+N<=90):
    #インクリンメント 次の文字を表示
    ans = ans + chr(ord(S_list[i]) + N)
  else:
    a = ord(S_list[i])+N - 90
    #print(a)
    ans = ans + chr(a+64)
  
print(ans)
chokudai
redcoder

### FIXED CODE ###

from collections import Counter
s=input()
t=input()
c1=Counter(s)
c2=Counter(t)
if sorted(c1.values())==sorted(c2.values()):
    print('Yes')
else:
    print('No')
from collections import Counter

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

d = dict(collections.Counter([i + A[i-1] for i in range(1, N+1)]))
ans = sum([d.get(i - A[i-1], 0) for i in range(1, N+1)])

print(ans)


### FIXED CODE ###

from collections import Counter

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

d = dict(Counter([i + A[i-1] for i in range(1, N+1)]))
ans = sum([d.get(i - A[i-1], 0) for i in range(1, N+1)])

print(ans)
def main():
    from builtins import int, map, list, print, len
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = sys.stdin.readline
    input_list = (lambda: input().rstrip().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    X = input_number()
    t = []
    i = 0
    while True:
        x = i ** 5
        t.append(x)
        if x > 10 ** 9:
            break
        i += 1
    d = {}
    for i in range(len(t)):
        for j in range(len(t)):
            d[t[i] - t[j]] = [i, j]
            d[t[i] + t[j]] = [i,-j]
            d[-t[i] - t[j]] = [-i, j]
            d[-t[i] + t[j]] = [-i, -j]
    print(d[X][0],d[X][1])

if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    from builtins import int, map, list, print, len
    import sys
    sys.setrecursionlimit(10 ** 6)

    X = int(input())
    t = []
    i = 0
    while True:
        x = i ** 5
        t.append(x)
        if x > 10 ** 12:
            break
        i += 1
    d = {}
    for i in range(len(t)):
        for j in range(len(t)):
            d[t[i] - t[j]] = [i, j]
            d[t[i] + t[j]] = [i, -j]
            d[-t[i] - t[j]] = [-i, j]
            d[-t[i] + t[j]] = [-i, -j]
    print(d[X][0], d[X][1])


if __name__ == '__main__':
    main()
H, K = map(int, input().split())
hp = list(int, map(input().split()))
hp.sort(reverse=True)
print(sum(hp[K:]))


### FIXED CODE ###

H, K = map(int, input().split())
hp = list(map(int, input().split()))
hp.sort(reverse=True)
print(sum(hp[K:]))
from collections import Counter

N, *a = map(int, open(0).read().split())
c = [y for _, y in sorted(Counter(a).most_common())]
print(max(sum(c[i:i + 3]) for i in range(len(c) - 2)))

### FIXED CODE ###

N, *a = map(int, open(0).read().split())
cnt = [0] * (10 ** 5 + 2)

for v in a:
    cnt[v] += 1
    cnt[v + 1] += 1
    cnt[v + 2] += 1
    
print(max(cnt))
x, y = map(int,input().split())
S1 = [1, 3, 5, 7, 8, 10, 12]
S2 = [4, 6, 9, 11]
for i in range(len(S1)):
  for j in range(len(S1)):
    if (S1[i] == x and s1[j] == y) or (S2[i] == x adn S2[j] == y):
      print("Yes")
    else:
      print("No")

### FIXED CODE ###

x, y = map(int,input().split())
S1 = [1, 3, 5, 7, 8, 10, 12]
S2 = [4, 6, 9, 11]
ans = False
for i in range(len(S1)):
  for j in range(len(S1)):
    if S1[i] == x and S1[j] == y:
      ans = True
for i in range(len(S2)):
  for j in range(len(S2)):
    if S2[i] == x and S2[j] == y:
      ans = True
if ans:
  print("Yes")
else:
  print("No")
while True:
    x,y = map(int, input().split())

    if x == 0 and y == 0:
        break;

    elif x => y:
        print(str(x) + " " + str(y))

    else:
        print(str(y) + " " + str(x))



### FIXED CODE ###

while True:
    x,y = map(int, input().split())

    if x == 0 and y == 0:
        break

    elif x <= y:
        print(str(x) + " " + str(y))
    else:
        print(str(y) + " " + str(x))
def rally():
    N=int(input())
    X=list(map(int,input().split()))
    dispersion=[]
    cnt=0
    for i in range(min(X),max(X)):
        for j in range(N):
            cnt+=abs(X[j]-i)**2
        dispersion.append(cnt)
        cnt=0
    print(min(dispersion))

rally()

### FIXED CODE ###

N=int(input())
X=list(map(int,input().split()))
dispersion=[]
cnt=0
for i in range(100):
    for j in range(N):
        cnt+=abs(X[j]-i)**2
    dispersion.append(cnt)
    cnt=0
print(min(dispersion))
input = input()
N = int(input)
input = input()
S = input
 
R = 0
B = 0
h = 'No'
 
for i in N:
  if S[i] == 'R':
    R += 1
  else:
    B += 1
  
if R > B:
  h = 'Yes'

print(h)

### FIXED CODE ###

input1 = input()
N = int(input1)
input2 = input()
S = list(input2)
 
R = 0
B = 0
h = 'No'
 
for i in range(N):
  if S[i] == 'R':
    R += 1
  else:
    B += 1
  
if R > B:
  h = 'Yes'

print(h)
n = int(input())
list1 = [int(x) for x in input().split()]
set1 = set(list1)

listans = []

for i in set1:
  if list1.count(i) > 2:
    listans.append(i)

if len(listans) < 2:
  print(0)
else:
  print(sorted(listans)[-1]*sorted(listans)[-2])

### FIXED CODE ###

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

if x > a:
	x_a = x - a
else:
	x_a = a - x

if x > b:
	x_b = x - b
else:
	x_b = b - x
	


if x_a > x_b:
	print("B")
else:
	print("A")
# -*- coding: utf-8 -*-

s = str(input())
n = len(s)

G = 0
P = 0

dic = dict()
for c in s:
	dic[c] = dic.get(c, 0) + 1

if n % 2 == 0:
	ans = (dic['g'] - dic['p']) / 2
else:
	ans = (dic['g'] - dic['p'] - 1) / 2

print(int(ans))



### FIXED CODE ###

# -*- coding: utf-8 -*-

s = str(input())
n = len(s)

G = s.count('g')
P = s.count('p')

ans = (G - P) // 2

print(ans)
HK=input().split(' ')
H=int(HK[0])
K=int(HK[1])
if K % 2==1 and H%2==1:
    print(round(HK/2)+1)
else:
    print(HK/2)

### FIXED CODE ###

HK=input().split(' ')
H=int(HK[0])
K=int(HK[1])
if H==1 or K ==1:
    print(1)
else:
    if K % 2==1 and H%2==1:
        print(round(H*K/2)+1)
    else:
        print(int(H*K/2))
n=int(input())
a=list(map(int,input().split()))
c=[0]*(max(a)+1)
for i in range(len(a)):
  c[a[i]]+=1
seta=set(a)
ans=0
for ai in seta:
  if c[ai]==ai:
    pass
  elif c[ai]<ai:
    ans+=c[ai]
  else:
    ans+=c[ai]-ai
print(ans)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
seta=set(a)
d=dict([[x,0] for x in seta])
for i in range(len(a)):
  d[a[i]]+=1
seta=set(a)
ans=0
for ai in seta:
  if d[ai]==ai:
    pass
  elif d[ai]<ai:
    ans+=d[ai]
  else:
    ans+=d[ai]-ai
print(ans)
if raw_input() == 'H': print raw_input() == 'H'
else: print raw_input() == 'D'

### FIXED CODE ###

inp = raw_input().split()

if inp[0] == 'H': print 'H' if inp[1] == 'H' else 'D'
else: print 'H' if inp[1] == 'D' else 'D'
n,a,b = map(int,input().split())
h =[0]*n
for i in range(n):
    h[i]=int(input())
def hantei(now):
    ab=a-b
    nokori = sum(kiriage( max(0,hh-now*b) ,ab)//ab  for hh in h)
    return nokori<=now
def kiriage(x,c):
    if x%c==0:
        return x
    else:
        return (x//c+1) *c

ma = 10**9//b +1
mi = 1
while mi<ma:
    now=(mi+ma)//2
    which = hantei(now)
#     print(which,mi,now,ma)
    if which:
        ma=now
        ans=now
    else:
        mi=now+1
print(ans)

### FIXED CODE ###

n,a,b = map(int,input().split())
h =[0]*n
for i in range(n):
    h[i]=int(input())

def hantei(now):
    ab=a-b
    nokori = sum(kiriage( max(0,hh-now*b) ,ab)//ab  for hh in h)
    return nokori<=now
def kiriage(x,c):
    if x%c==0:
        return x
    else:
        return (x//c+1) *c

ma = 10**9 +1
mi = 1

while mi<ma:
    now=(mi+ma)//2
    which = hantei(now)
#     print(which,mi,now,ma)
    if which:
        ma=now
        ans=now
    else:
        mi=now+1
print(ans)
num = input()
listt = input().split()

def hoge(fuga):
    new_list = []
    for i in fuga:
        if int(i) % 2 == 0:
            new_list.append(i/2)
        else:
            return False
    return new_list


count = 0
while True:
    listt = hoge(listt)
    if listt == False:
        break
    count += 1

print(count)


### FIXED CODE ###

num = input()
listt = input().split()

def hoge(fuga):
    new_list = []
    for i in fuga:
        if int(i) % 2 == 0:
            new_list.append(int(i)/2)
        else:
            return False
    return new_list


count = 0
while True:
    listt = hoge(listt)
    if listt == False:
        break
    count += 1

print(count)
X = int(input())

for a in range(-300, 300):
    for b in range(-300, 300):
        if a ** 5 - b ** 5 == X:
            print(str(A) + " " + str(B))
            exit()

### FIXED CODE ###

X = int(input())

for a in range(-300, 300):
    for b in range(-300, 300):
        if a ** 5 - b ** 5 == X:
            A = a
            B = b

print(str(A) + " " + str(B))
def Input():
    return mapt(int, input().split(" "))

  
def main():
    a, b = Input()
    return max(a*b, a-b, a+b)


print(main())

### FIXED CODE ###

def Input():
    return map(int, input().split(" "))

def main():
    a, b = Input()
    return max(a*b, a-b, a+b)


print(main())
#!/usr/bin/env python3

#import
#import math
#import numpy as np
#= int(input())
S = input()
K = int(input())
ls = len(S)
t1 = []

t = 1
for i in range(1, ls):
    if S[i - 1] == S[i]:
        t += 1
    else:
        if t > 1:
            t1.append(t)
        t = 1

if t > 1:
    t1.append(t)

ans = 0
for t in t1:
    ans += t // 2

if len(t1) == 1:
    if t1[0] == ls:
        print(ls * K // 2)

else:
    if S[0] != S[1]:
        print(ans * K)
    
    else:
        ta = t1[0]
        tb = t1[-1]
        print(ans * K - (ta // 2 + tb // 2 - (ta + tb) // 2) * (K - 1))






### FIXED CODE ###

#!/usr/bin/env python3

#import
#import math
#import numpy as np
#= int(input())
S = input()
K = int(input())
ls = len(S)
t1 = []

t = 1
for i in range(1, ls):
    if S[i - 1] == S[i]:
        t += 1
    else:
        if t > 1:
            t1.append(t)
        t = 1

if t > 1 or t == ls:
    t1.append(t)

ans = 0
for t in t1:
    ans += t // 2

if len(t1) == 1:
    if t1[0] == ls:
        print(ls * K // 2)

else:
    if S[0] != S[-1]:
        print(ans * K)
    
    else:
        ta = t1[0]
        tb = t1[-1]
        print(ans * K - (ta // 2 + tb // 2 - (ta + tb) // 2) * (K - 1))
n,k = map(int,input().split())
s = list(input())
s[k] = s[k].lower()
str = "".join(s)
print(str)

### FIXED CODE ###

n,k = map(int,input().split())
s = list(input())
s[k-1] = s[k-1].lower()
st = "".join(s)
print(st)
x,y=map(int, input().split())
while x != 0 or y != 0 :
 if x<y :
  print(x + " " + y)
 else :
  print(y + " " + x)

### FIXED CODE ###

x, y = map(int, input().split())
while not( x == 0 and y == 0 ):
 if x < y : print(x, y)
 else : print(y, x)
 x, y = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))
# print(A)

cnt = {}
for a in A:
  if a not in cnt:
    cnt[a] = 1
  else:
  	cnt[a] += 1
  
s, e = 1, 100000
while True:
  while (s not in cnt or cnt[s] <= 1) and s < e:
    s += 1
  while (e not in cnt or cnt[e] <= 1) and s < e:
    e -= 1
  if e < s:
    break
  if s == e and cnt[s] <= 1:
    break
  if s in cnt:
  	cnt[s] -= 1
  if e in cnt:
    cnt[e] -= 1

ans = 0
for i in range(1, 100001):
  if i in cnt and cnt[i] > 0:
    ans += 1
    
print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
# print(A)

cnt = {}
for a in A:
  if a not in cnt:
    cnt[a] = 1
  else:
  	cnt[a] += 1
  
s, e = 1, 100000
while True:
  while (s not in cnt or cnt[s] <= 1) and s < e:
    s += 1
  while (e not in cnt or cnt[e] <= 1) and s < e:
    e -= 1
  if e < s:
    break
  if s == e:
    if s in cnt:
      if cnt[s] <= 1:
        break
    else:
      break
  if s in cnt:
  	cnt[s] -= 1
  if e in cnt:
    cnt[e] -= 1

ans = 0
for i in range(1, 100001):
  if i in cnt and cnt[i] > 0:
    ans += 1
    
print(ans)
N, A, B, C = map(int, input().split())
    l = [int(input()) for _ in range(N)]

    def dfs(i, a, b, c, x):
        if i == N:
            return (abs(A - a) + abs(B - b) + abs(C - c) + 10 * (x - 3)) if a * b * c != 0 else 10 ** 9
        ret1 = dfs(i + 1, a, b, c, x)
        ret2 = dfs(i + 1, a + l[i], b, c, x + 1)
        ret3 = dfs(i + 1, a, b + l[i], c, x + 1)
        ret4 = dfs(i + 1, a, b, c + l[i], x + 1)
        return (min(ret1, ret2, ret3, ret4))


### FIXED CODE ###

N,A,B,C=map(int,input().split())
l=[int(input())for _ in range(N)]
def dfs(i,a,b,c,x):
    if i==N:
        return(abs(A-a)+abs(B-b)+abs(C-c)+10*(x-3))if a*b*c!=0 else 10**9
    ret1=dfs(i+1,a,b,c,x)
    ret2=dfs(i+1,a+l[i],b,c,x+1)
    ret3=dfs(i+1,a,b+l[i],c,x+1)
    ret4=dfs(i+1,a,b,c+l[i],x+1)
    return(min(ret1,ret2,ret3,ret4))
print(dfs(0,0,0,0,0))
a=int(input())
b=int(input())
if a>b:
    print("GREATER")
elif a<b:
    print("LESS")
else:
    print("EQUAL")

### FIXED CODE ###

a = input().split()
out = ""
for s in a:
  out += s[0].upper()
print(out)
a = input()
b = input()

if a < b:
 print "a < b"
if a == b:
 print "a = b"
if a > b:
 print "a > b"

### FIXED CODE ###

a, b = map(int, raw_input().split())
    
if a < b:
 print "a < b"
elif a > b:
 print "a > b"
else:
 print "a == b"
n,m,X,Y=map(int, input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))

if max(x,X)<min(y,Y):
    print("No war")
else:
    print("War")

### FIXED CODE ###

n,m,X,Y=map(int, input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
x.append(X)
y.append(Y)
if max(x)<min(y):
    print("No War")
else:
    print("War")
# https://atcoder.jp/contests/abc103/tasks/abc103_d

def solve(n, pairs):
    pairs.sort(key=lambda pair: pair[1])
    cnt = 0
    while pairs:
        _, b0 = pairs[0]
        cnt += 1
        for (a, b) in pairs:
            if a < b0:
                pairs.remove((a, b))
    return cnt

n, m = map(int, input().split())
pairs = [[int(c) for c in input().split()] for _ in range(m)]
print(solve(n, pairs))

### FIXED CODE ###

# https://atcoder.jp/contests/abc103/tasks/abc103_d
import sys

def solve():
    pairs.sort(key=lambda pair: pair[1])
    cnt = 0
    base = 0
    for (a, b) in pairs:
        if a >= base:
            cnt += 1
            base = b
    return cnt

n, m = map(int, input().split())
pairs = [tuple(int(c) for c in input().split()) for _ in range(m)]
print(n, pairs, file=sys.stderr)
print(solve())
import bisect


def CumulativeSum(l):
    a = [0]
    for i in l:
        a.append(a[-1] + i)
    return a[1:]


def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    b = CumulativeSum(a)
    s = b[-1]
    h = s // 2
    x = bisect.bisect_left(b, h)
    if x != len(a):
        m = (b[x], b[x + 1], b[x - 1])
    else:
        m = (b[x], b[x - 1])
    if s % 2 == 0 and h in m:
        print(0)
        return

    print(min([abs(x * 2 - s) for x in m]))


if __name__ == '__main__':
    resolve()


### FIXED CODE ###

import bisect


def CumulativeSum(l):
    a = [0]
    for i in l:
        a.append(a[-1] + i)
    return a[1:]


def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    b = CumulativeSum(a)
    s = b[-1]
    h = s // 2
    x = bisect.bisect_left(b, h)
    try:
        m = (b[x], b[x + 1], b[x - 1])
    except:
        m = (b[x], b[x - 1])
    if s % 2 == 0 and h in m:
        print(0)
        return

    print(min([abs(x * 2 - s) for x in m]))


if __name__ == '__main__':
    resolve()
import math
a,b,c = map(int,input().split())
print("YES") if c%math.gcd(a,b)==0 else print("NO")

### FIXED CODE ###

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

a,b,c = map(int,input().split())
print("YES") if c%gcd(a,b)==0 else print("NO")
a, b, c = map(int, input().split())
print(upper(a[0] + b[0] + c[0]))

### FIXED CODE ###

a, b, c = map(str, input().split())
print((a[0] + b[0] + c[0]).upper())