peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
N = int(input())
a = list(map(int,input().split()))
s = sum(a)
su = a[0]
ar = s - su
ans = abs(su-ar)
for i in range(1,N-1):
    su += a[i]
    ar = s - su
    if ans > abs(su-ar):
        ans = abs(su-ar)
print(ans)
# Judge status: Accepted
k, n = map(int, input().split())
List = list(map(int, input().split()))

L2 = []

for i in range(n-1):
    L2.append(List[i+1] - List[i])
L2.append(k - List[-1] + List[0])
print(k - max(L2))
# Judge status: Wrong Answer
from decimal import *

getcontext().prec = 100
a, b, c = map(int, input().split())

l = Decimal(a).sqrt() + Decimal(b).sqrt()
r = Decimal(c).sqrt()

if l < r:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a = [list(map(int, input().split())) for i in range(3)]
n = int(input())
for i in range(n):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k] == b:
                a[j][k] = 0

cross = 0
ucross = 0
for j in range(3):
    if sum(a[j][:]) == 0 or sum([row[j] for row in a]) == 0:
        print("Yes")
        exit()
    cross += a[j][j]
    ucross += a[2-j][j]
if cross == 0 or ucross == 0:
    print("Yes")
    exit()

print("No")
# Judge status: Accepted
a,b,t = map(int, input().split())
ans = int((t+0.5)//a)*b
print(ans)
# Judge status: Accepted
a, b,c = map(int, input().split())
if a+b >=c:
    print('Yes', flush=True)
else:
    print('No', flush=True)
# Judge status: Accepted
import sys
input = sys.stdin.readline
K, A, B = map(int, input().split())
if A >= B:
  print(K + 1)
  exit(0)
if K <= A:
  print(K + 1)
  exit(0)
print(max(K + 1, ((K - A + 1) // 2) * (B - A) + A * (((K - A + 1) // 2) > 0) + (((K - A + 1) % 2))))
# Judge status: Wrong Answer
N=int(input())
A=sorted(map(int,input().split()))
ans=0
for i in range(N-1):
  ans+=A[i]

if ans<A[N-1]:
  print("No")
else:
  print("Yes")
# Judge status: Accepted
import collections as c

n = int(input())
s = []
ans = 0

for i in range(n):
    t = list(input())
    t.sort()
    t = str(t)
    s.append(t)

s = c.Counter(s)
for i in s.values():
    ans += i*(i-1)//2
print(ans)
# Judge status: Wrong Answer
import heapq

N, M = map(int, input().split())
L = []
for i in range(N):
    a, b = map(int, input().split())
    L.append((a, b))

heapq.heapify(L)
# heapq.heapify(sorted(L, key=lambda x: x[0]))
print(L)
drink = 0
yen = 0
while drink < M:
    a, b = heapq.heappop(L)
    if drink + b <= M:
        yen += a * b
        drink += b
    else:
        yen += a * (M - drink)
        break
print(yen)
# Judge status: Wrong Answer
A, B, C = input().split()
A, B, C = [int(A), int(B), int(C)]
K = int(input())

for i in range(K):
    if(B > C or A > C):
        C = C * 2
    elif(A > B):
        B = B * 2
    else:
        C = C * 2

if(C > B > A):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
s, c = map(int, input().split())
ans = 0
ans += min(s,c//2)
res = c-min(s,c//2)*2
ans += res//4
print(ans)
# Judge status: Wrong Answer
A = input()
B = input()
C = input()

ABC = {"a":A, "b":B, "c":C}
ABC_H = {"a":"A", "b":"B", "c":"C"}
ind = A[0]

while True:

    if len(ABC[ind]) == 0:
        print(ABC_H[ind])
        break 
    ind = ABC[ind][0]
    ABC[ind] = ABC[ind][1:]
# Judge status: Accepted
#!/usr/bin/env python3
import sys


def solve(L: int):
    x = L / 3
    print(x**3)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = int(next(tokens))  # type: int
    solve(L)

if __name__ == '__main__':
    main()
# Judge status: Accepted
import sys
input = sys.stdin.readline


def main():
    H = int(input())
    W = int(input())
    N = int(input())

    print(min(-((-N) // H),-((-N) // W)))



if __name__ == '__main__':
    main()
# Judge status: Accepted
a,b = map(int,input().split())
if a < b:
        print("{}".format(a)*b)
else:
        print("{}".format(b)*a)
# Judge status: Accepted
A,B,K=map(int,input().split())
for i in range(A,min(B+1,A+K)):
  print(i)
for i in range(max(B-K+1,A+K),B+1):
  print(i)
# Judge status: Wrong Answer
n = int(input())
ab = [map(int, input().split()) for _ in range(n)]
a, b = [list(i) for i in zip(*ab)]
 
a.reverse()
b.reverse()
ans = 0
num = 0
ruisekiwa = 0

for j in range(n):
  a[j] += ruisekiwa
  syou = a[j]//b[j]
  if a[j] == 0:
    num = 0
  elif b[j] == 1:
    num = 0
  elif a[j] == b[j]:
    num = 0
  else:
    num = b[j]*(syou+1) - a[j]
  ruisekiwa += num
  ans += num

print(ans)
# Judge status: Accepted
A,B,C,D=map(int,input().split())
s=min(B,D)-max(A,C)
if s<0:
  print(0)
else:
  print(s)
# Judge status: Wrong Answer
k, a, b = map(int, input().split())

if k > a+1 and a < b:
    print(max((k-a-1) // 2 * (b-a) + b + (k-a-1) % 2, k+1))
else:
    print(k+1)
# Judge status: Accepted
A, B = map(int, input().split())

print(A+B if A+B<24 else A+B-24)
# Judge status: Wrong Answer
a, b, c, d = map(int, input().split())
if b <= 0 and d <= 0:
    print(c * a)

elif b > 0 and d > 0:
    print(b * d)

elif b < 0 and d > 0:
    if c > 0:
        print(c * b)
    else:
        print(a * c)

elif b > 0 and d < 0:
    if a > 0:
        print(a * d)
    else:
        print(a * c)

else:
    print(b * d)
# Judge status: Accepted
def main():
    N = int(input())
    p = list(map(int,input().split()))
    count = 0
    for i in range(N-1):
        if p[i]!=i+1:
            count += 1
    
    if count >= 3:
        print("NO")
    else:
        print("YES")


if __name__=="__main__":
    main()
# Judge status: Accepted
n = int(input())
A = list(map(int, input().split()))

Alice = 0
Bob = 0

A = list(sorted(A, reverse=True))

while True:
    if A != []:
        Alice += A.pop(0)
    else:
        break
    if A != []:
        Bob += A.pop(0)
    else:
        break

print(Alice-Bob)
# Judge status: Accepted
n,m = map(int, input().split())
if n % m == 0:
  print(-1)
else:
  print(n*(m+1))
# Judge status: Accepted
import sys 
input = sys.stdin.readline

N = int(input())
a = list(map(int,input().split()))
a.insert(0,-1)

for i in range(N,0,-1):
    k=2
    temp=a[i]
    while i*k<=N:
        if a[i*k]==1:
            temp = (temp+1)%2
        k+=1
    a[i] = temp

M=0
b=[]
for i in range(1,N+1):
    if a[i]==1:
        M+=1
        b.append(i)

print(M)
[print(x) for x in b]
# Judge status: Wrong Answer
s = input()
t = input()
a = 0
for i in range(len(s)):
  if s[i] == t[i]:
    a += 1
    
print(a)
# Judge status: Wrong Answer
import numpy as np


N = int(input())
L = list(map(int, input().split()))
maxL = np.argmax(L)
L.pop(maxL)
if maxL < sum(L):
  print('Yes')
else:
  print('No')
# Judge status: Accepted
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def solve(inp):
    import math
    (H, A) = map(int, inp.readline().strip().split(' '))

    r = math.ceil(H / A)
    return r


def main():
    import sys
    result = solve(sys.stdin)
    if result is not None and result != '':
        print(result)


if __name__ == '__main__':
    main()
# Judge status: Accepted
n=int(input())
a=set()
b=[]
import collections
for i in range(n):
    s=input()
    s=sorted(s)
    a.add("".join(s))
    b.append("".join(s))
ans=0
a=list(a)
c=collections.Counter(b)
for i in range(len(a)):
    ans+=c[a[i]]*(c[a[i]]-1)//2
print(ans)
# Judge status: Wrong Answer
s = input()
n = len(s)
flg=False
for i in range(n-1):
    if(s[i] == s[i+1]):
        flg=True
        break

if flg:
    print("yes")
else:
    print("no")
# Judge status: Wrong Answer
def main():
    S = input()
    N = len(S)
    P = S[:(N-1)//2]
    Q = S[(N+3)//2 - 1:]
    if (P[:len(P)//2] == P[len(P)//2 + 1:]) and (Q[:len(Q)//2] == Q[len(Q)//2 + 1:]):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()
# Judge status: Accepted
X, Y = map(int, input().split())

A = []
a = X

while 1:
    A.append(a)
    if a*2 > Y:
        break
    a *= 2

print(len(A))
# Judge status: Accepted
N, M = map(int, input().split())
S = []
for i in range(N):
  a, b = map(int, input().split())
  S.append([a, b])

S.sort(key=lambda x: x[0])
price = 0
count = 0
for s in S:
  if count + s[1] < M:
    price += s[0] * s[1]
    count += s[1]
  else:
    price += s[0] * (M - count)
    break

print(price)
# Judge status: Wrong Answer
n = int(input())
ans = 0
if n < 10:
  ans += n
else:
  ans += 9
  if n < 10000:
    ans += max(0, n-1000)
  else:
    ans += 900
    if n < 1000000:
      ans += max(0, n-100000)
print(ans)
# Judge status: Wrong Answer
a, b, c = map(int, input().split())
print(max(a*10+b+c, a+b*10+c), a+b+c*10)
# Judge status: Accepted
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
d = set(map(int, input().split()))
for x in range(N, 10 ** 6):
  f = 1
  for y in str(x):
    if int(y) in d:
      f = 0
      break
  if f:
    print(x)
    exit(0)
# Judge status: Wrong Answer
s,t=input(),input()
for i in range(len(s)-len(t)+1):
  judge = True
  for j in range(len(t)):
    if not (s[i+j]==t[j] or s[i+j]=='?'):
      judge = False
    if not judge:
      break
  else:
    r=['a' if i=='?' else i for i in s[:i]]
    print(''.join(r)+t)
    exit()
print('UNRESTORABLE')
# Judge status: Accepted
s = [ord(i) for i in input()]
k = int(input())
for i in range(len(s)):
    if s[i] == 97: continue
    if 123 - s[i] <= k:
        k -= 123 - s[i]
        s[i] = 97
        if k == 0:
            break
if k != 0:
    s[-1] = s[-1] + k % 26
print("".join([chr(i) for i in s]))
# Judge status: Accepted
w, h, x, y = map(int, input().split())
center = (w/2, h/2)
ans2 = 1 if (x, y)==center else 0
ans1 = w*h/2
print(ans1, ans2)
# Judge status: Accepted
N = int(input())
P = list(map(int, input().split()))

cnt = 0
t = 'o' if P[0] == 1 else 'x'
j = 0 if t == 'o' else 1
L = []
for i, p in enumerate(P):
    s = 'o' if p == (i + 1) else 'x'
    if s == t:
        cnt += 1
    else:
        L.append(cnt)
        cnt = 1
        t = s
L.append(cnt)

ans = 0
for i, n in enumerate(L):
    if i % 2 == j:
        ans += (n + 2 - 1) // 2

print(ans)
# Judge status: Wrong Answer
n,a,b=list(map(int,input().split()))
import math
mod=10**9+7
x=math.factorial(n)//(math.factorial(n-a)*math.factorial(a))
y=math.factorial(n)//(math.factorial(n-b)*math.factorial(b))
def power(n,a,p):
    res=1
    while n>0:
        if n%2:
            res=(res*a)%p
            n-=1
        else:
            a=(a*a)%p
            n/=2
    return res
print((power(2,n,mod)-1-x-y)%mod)
# Judge status: Accepted
n,m=map(int,input().split())
al=[]
bl=[]
for i in range(m):
  a,b=map(int,input().split())
  al.append(a)
  bl.append(b)

for i in range(1,n+1):
  print(al.count(i)+bl.count(i))
# Judge status: Accepted
n = int(input())

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

count = 0

for i in range(n):
  if(i != 0):
    if(a[i] - a[i - 1] == 1):  
      count += b[a[i] - 1] + c[a[i - 1] - 1]
    else:
      count += b[a[i] - 1]
  else:
    count += b[a[i] - 1]

print(count)
# Judge status: Accepted
import sys

n, *a = map(int, sys.stdin.read().split())
a = [None] + a

def main():
    res = [0] * (n + 1)
    chosen = []
    for i in range(n, 0, -1):
        tmp = sum(res[i*2:n+1:i]) & 1
        if tmp ^ a[i]:
            res[i] = 1
            chosen.append(i)

    if chosen:
        m = len(chosen)
        return [m], chosen[::-1]
    else:
        return [[0]]

if __name__ == '__main__':
    ans = main()
    for a in ans:
        print(*a, sep=' ')
# Judge status: Accepted
a,b = map(int,input().split())
S = input()
flag = 0
k = [str(i) for i in range(10)]
for i in range(len(S)):
  if i == a:
    if S[i] == "-":
      continue
    else:
      flag += 1
      print("No")
      break
  else:
    if S[i] in k:
      continue
    else:
      flag += 1
      print("No")
      break
if flag == 0:
  print("Yes")
# Judge status: Accepted
import math

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

cnt = -1
for i in range(1, 1001):
    hachi = math.floor(i * 0.08)
    ju = math.floor(i * 0.1)
    if hachi == a and ju == b:
        cnt = i
        break


print(cnt)
# Judge status: Accepted
s = input()
n = len(s) - 7
for i in range(7):
    if s[:i] + s[i+n:] == 'keyence':
        print("YES")
        exit()
print("NO")
# Judge status: Wrong Answer
A, B, C = input().split()
ans1 = int(A+B) + int(C)
ans2 = int(A) + int(B+C)

print(max(ans1, ans2))
# Judge status: Wrong Answer
n = int(input())
ng =0
ok=n
while abs(ok-ng)>1:
  mid=(ok+ng)//2
  if mid*(1+mid)//2>=n:
    ok=mid
  else:
    ng = mid
if ok*(1+ok)//2 != n:
  ok+=1
print(ok)
# Judge status: Accepted
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(n)]
cd=[list(map(int,input().split())) for _ in range(m)]

ans=[]
for i in range(n):
    MIN=10**10
    index=0
    for g in range(m):
        if MIN>abs(ab[i][0]-cd[g][0])+abs(ab[i][1]-cd[g][1]):
            MIN=abs(ab[i][0]-cd[g][0])+abs(ab[i][1]-cd[g][1])
            index=g+1
    ans.append(index)

for i in range(n):
    print(ans[i])
# Judge status: Wrong Answer
s = input()
if s[-1]=="s":
  print(s+"es")
else:
  print(s)
# Judge status: Accepted
from bisect import bisect_left
n = int(input())
lis = [0]*13
for i in range(1,13):
   lis[i] = 26**i + lis[i-1]
#print(lis)
num = bisect_left(lis,n)
n -= lis[num-1]
n -= 1
ans = ''
for i in range(num):
   i = num-i-1
   ans += chr(n//(26**i) +97)
   n %= 26**i
print(ans)
# Judge status: Accepted
import fractions
a,b=map(int, input().split())
f=fractions.gcd(a,b)
f2=a*b//f
print(f2)
# Judge status: Accepted
n, l = map(int, input().split())
a = [input() for _ in range(n)]
a.sort()
print("".join(a))
# Judge status: Accepted
n,m = map(int,input().split())
ab = [0]*n
cd = [0]*m

for i in range(n):
  ab[i] = input().split()
  
for i in range(m):
  cd[i] = input().split()
  
for i in range(n):
  tmp = []
  for j in range(m):
    tmp.append(abs (int(ab[i][0]) - int(cd[j][0])) + abs(int(ab[i][1]) - int(cd[j][1])))
  x = min(tmp) 
  ans = tmp.index(x)
  print(ans+1)
# Judge status: Accepted
#starting from X is equivalent to go to x1-X,x2-X,... starting from 0.
#donc x1-X est multiple de D, x2-X l'est aussi...donc gcd des xi-X.
import fractions
from functools import reduce
N,X = map(int,input().split())
L = [abs(i-X) for i in map(int,input().split())]
def gcd_list(numbers):
  return reduce(fractions.gcd,numbers)
print(gcd_list(L))
# Judge status: Accepted
n,m = map(int,input().split())
 
if (n == 2 and m != 1) or (m == 2 and n != 1):
  print(0)
elif n ==1 and m != 1:
  print(m-2)
elif m == 1 and n != 1:
  print(n-2)
elif n == 1 and m == 1:
  print(1)
else:
  print(n*m-(n+m-2)*2)
# Judge status: Accepted
n=int(input())
print(sum(sorted(list(map(int,input().split())),reverse=True)[1:2*n:2]))
# Judge status: Accepted
import sys

N, M = map(int, sys.stdin.readline().strip().split())

if N >= M // 2:
    print(M // 2)
else:
    ans = N
    r = M - N*2
    ans += r // 4
    print(ans)
# Judge status: Accepted
A, B, K = map(int, input().split())

e = min([K, A])
a = A - e
e = min([K-e, B])
b = B - e
print(a, b)
# Judge status: Accepted
s = input()
if s in ["a", "i", "u", "e", "o"]: print("vowel")
else: print("consonant")
# Judge status: Accepted
from fractions import gcd

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

A, B = map(int, input().split())
N = gcd(A, B)
l = set(prime_factorize(N))
print(len(l)+1)
# Judge status: Wrong Answer
import math

s = input()

left = s[:len(s) // 2]
right = s[-math.floor(len(s) / 2):]

ct = 0
for i in range(len(left)):
    if left[i] != right[i]: ct += 1

print(ct)
# Judge status: Accepted
from collections import Counter


MOD = 10 ** 9 + 7
input()
S = input()
ans = 1
for v in Counter(S).values():
    ans *= v + 1
    ans %= MOD
print(ans - 1)
# Judge status: Wrong Answer
A,B,C=input().split()
if(A==B):
  if not(B==C):
    print("Yes")
elif(A==C):
  if not(A==B):
    print("Yes")
elif(C==B):
  if not(C==A):
    print("Yes")
else:
  print("No")
# Judge status: Accepted
N = int(input())

ABCDE = [int(input()) for _ in range(5)]

tmp = min(ABCDE)

ans = (N + tmp - 1) // tmp + 4

print (ans)
# Judge status: Accepted
n,m=map(int,input().split())
print((n+m)*(n+m-1)//2-n*m)
# Judge status: Accepted
n,l = map(int,input().split())
s = sorted([input() for i in range(n)])
print("".join(s))
# Judge status: Accepted
n=int(input())-1;print(sum(n//-~i for i in range(n)))
# Judge status: Accepted
import sys

input = sys.stdin.readline

def main():
    t = 'ATGC'
    ans = 0
    S = input()
    temp = 0
    for s in S:
        if s in t:
            temp += 1
        else:
            ans = max(ans, temp)
            temp = 0

    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Accepted
import itertools
x = int(input())
count = 0
c=list(map(int, input().split()))
c_list = list(itertools.combinations_with_replacement(c, 3))
for i in range(len(c_list)):
  if c_list[i][0] != c_list[i][1] and c_list[i][1]!= c_list[i][2] and c_list[i][2] != c_list[i][0]:
    if c_list[i][0] + c_list[i][1]  > c_list[i][2] and c_list[i][1] + c_list[i][2] > c_list[i][0] and c_list[i][0] + c_list[i][2] > c_list[i][1]:
      count += 1
print(count)
# Judge status: Wrong Answer
import sys

stdin = sys.stdin

mod = 1000000007

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

n = ni()
a = na()

ans = 0
for i in range(61):
	z, o = [0] * 2
	for j in range(n):
		if a[j] & (1 << i):
			o += 1
		else:
			z += 1
	ans += z * o * (2 ** i)

print(ans)
# Judge status: Wrong Answer
n = int(input())
x = round(n / 1.08)
d = int(x * 1.08)
if n == d:
    print(x)
else:
    print(":(")
# Judge status: Wrong Answer
# 計算
X = 1000000000
uresisa_500yen = (X // 500) * 1000
mod = (X % 500)
uresisa_5yen = (mod // 5) * 5

uresisa_total = uresisa_500yen + uresisa_5yen
print(uresisa_total)
# Judge status: Accepted
n=int(input())
a,b=[],[]
for _ in range(n):
    a_,b_=map(int,input().split())
    a.append(a_)
    b.append(b_)
a.sort()
b.sort()
if n%2:
    print(b[n//2]-a[n//2]+1)
else:
    lower=(a[n//2]+a[n//2-1])/2
    upper=(b[n//2]+b[n//2-1])/2
    print(int(upper*2-(lower*2-1)))
# Judge status: Wrong Answer
[n,m] = [int(i) for i in input().split()]
if n * 2 >= m:
    print(n)
else:
    ans = n
    m -= n * 2
    ans += m//4
    print(ans)
# Judge status: Accepted
n,x = map(int,input().split())
a = list(map(int,input().split()))
if sum(a) == x:
    print(n)
elif sum(a) < x:
    print(n - 1)
else:
    ans = 0
    a.sort()
    for i in range(n):
        if a[i] > x:
            break
        else:
            x -= a[i]
            ans += 1
    print(ans)
# Judge status: Accepted
def main():
    X = input()
    cs, ct = 0, 0
    for x in X:
        if x == 'T':
            if cs == 0:
                ct += 1
            else:
                cs -= 1
        else:
            cs += 1
    print(ct * 2)
if __name__ == '__main__':
    main()
# Judge status: Accepted
s = input()
Q = int(input())

rev_count = 0
sbf=''
saf=''
for i in range(Q):
    que = input()
    if que[0] == '1':
        rev_count +=1
    elif que[0] == '2':
        if (rev_count + int(que[2]))%2 == 0:
            saf = saf + que[4]
        else:
            sbf = que[4] + sbf

print(sbf+s+saf if rev_count %2 == 0 else (sbf+s+saf)[-1::-1])
# Judge status: Accepted
N=int(input())
p=list(map(int,input().split()))
z=0
for i in range(N):
  if p[i]!=i+1:
    z+=1
if z<=2:
  print("YES")
else:
  print("NO")
# Judge status: Wrong Answer
def candy():
    boxNum, x = [int(i) for i in input().split()]
    ain = input()
    alist = ain.split(' ')

    s = 0
    for i in range(0, boxNum-1):
        if int(alist[i+1]) + int(alist[i]) > x:
            s = s + (int(alist[i+1]) + int(alist[i]) - x)
            alist[i+1] = x - int(alist[i])
        
    print(s)
    
candy()
# Judge status: Accepted
n=int(input())
R=[list(input().split()) + [i+1] for i in range(n)]
R.sort(key=lambda x: (x[0],-int(x[1])))
for r in R:
    print(r[2])
# Judge status: Wrong Answer
from collections import Counter 
from collections import defaultdict
from collections import deque
import math
import itertools
import heapq
import sys
sys.setrecursionlimit(10**6)

#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
input_list = lambda : list(map(int,input().split()))

a,b=input_list()
ans=0
if b>12:
    ans=a
if 13>b and b>5:
    ans=a//2

print(ans)
# Judge status: Accepted
length = list(map(int, input().split()))
judge = {0:5,1:7,2:5}

for i in range(len(judge)):
    for j in range(len(length)):
        if length[j] == judge[i]:
            length.pop(j)
            break
        else:
            if j == len(length)-1:
                print('NO')
                exit()
print('YES')
# Judge status: Accepted
# -*- coding: utf-8 -*-
# Input of 3 stations
stations = input() # i.e. ABA

def needBus(s):
  '''<str> s: 3 stations'''
  if ((s[0] != s[1]) or (s[1] != s[2])):
    return 'Yes'
  else:
    return 'No'
  
# Output
print(needBus(stations))
# Judge status: Accepted
n = int(input())
n_str = str(n)
ans = int(n_str[0])
if n_str[1:].count('9') != len(n_str) - 1:
    ans -= 1
ans += int(len(n_str[1:])) * 9
print(ans)
# Judge status: Wrong Answer
x,k,d = input().split()
x = int(x)
k = int(k)
d = int(d)
ans = 0
if abs(x) > abs(k*d):
    ans =  abs(x) - abs(k*d)
else:
    kaisuu = abs(x)/d
    k_2 = k - kaisuu
    if k_2/2 == 2:
        ans = abs(x) - d*kaisuu 
    else:
        ans = (abs(x) - d*kaisuu) - d
print(ans)
# Judge status: Accepted
if __name__ == '__main__':
    a, b, c = tuple([int(n) for n in input().split()])
    if c - a - b < 0:
        print('No')
    elif (c - a - b) * (c - a - b) > 4 * a * b:
        print('Yes')
    else:
        print('No')
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

j = 0
l = len(A)

while 1:
    count = 0
    for i in A:
        if i % 2 == 0:
            count += 1

    if count == l:
        j += 1
        for i in range(l):
            A[i] = A[i] // 2
    else:
        break

print(j)
# Judge status: Accepted
n=int(input())

t = list(map(int,input().split()))

for i in range(n-1, 0, -1):
    #print(t)
    if t[i] < t[i-1]-1:
        print('No')
        exit()
    elif t[i] == t[i-1]-1:
        t[i-1] -= 1
print('Yes')
# Judge status: Accepted
w, a, b = map(int, input().split())
if (a <= b and b <= a + w) or (a <= b + w and b + w <= a + w):
    print(0)
else:
    print(min(abs(a + w - b), abs(b + w - a)))
# Judge status: Accepted
S = input()
search = "keyence"
for i in range(len(search)):
    if S[:i] + S[len(S) - (len(search) - i):] == search:
        print("YES")
        break
else:
    print("NO")
# Judge status: Accepted
a, b, n = map(int, input().split())
syou = n // b
if syou >= 1:
    n = b * 1 - 1
 
print(int((a * n) / b) - a * int(n / b))
# Judge status: Accepted
def main():
    n = int(input())
    a = list(map(int, input().split()))
    
    s = sum(a)
    minx = s
    sum_a = 0

    for i in range(n):
        sum_a += a[i]
        minx = min(minx, abs(sum_a - (s - sum_a)))

    print(minx)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
import collections
import math


def main():
    x, y = map(int, input().split())

    if x % y == 0 or y % x == 0:
        print(-1)
        return
    print(x)


if __name__ == '__main__':
    main()
# Judge status: Accepted
n = int(input())
x = n/1.08
if x != int(x):
  x = int(x) + 1
else:
  x = int(x)
if n == int(x*1.08):
  print(x)
else:
  print(":(")
# Judge status: Accepted
a=int(input())
ct=1
if a==1:
  print(4)
  exit()
elif a==2:
  print(4)
  exit()
while a!=1:
  ct+=1
  if a%2==0:
    a=a//2
  else:
    a=3*a+1
else:
  ct+=1
  print(ct)
# Judge status: Accepted
a,b,c=map(int,input().split())
if b//a <= c:
    print(b//a)
else:
    print(c)
# Judge status: Wrong Answer
A,B = map(int, input().split())
print(max(2*A-1,2*B-1))
# Judge status: Accepted
n = int(input())
for i in range(1, 2*10**5):
    score = (i*(i+1))//2
    if score >= n:
        print(i)
        exit()