peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
s=list(map(int,input().split()))
k=int(input())
s.sort()
m=1
m *= s[2]*(k+1)
print(m+s[0]+s[1])
# Judge status: Accepted
n, m = map(int, input().split())
a = []
for i in range(n):
    a += (list(map(int, input().split()))[1:])

ans = 0
for i in range(1, m + 1):
    if a.count(i) == n:
        ans += 1

print(ans)
# Judge status: Accepted
n=int(input())
a=sorted(list(map(int,input().split())),reverse=True)
ans=sum(a[1::2][:n])
print(ans)
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))

ans = 100000000
for i in range(-100, 101):
    s = 0
    for j in a:
        s += (j - i) **2
    ans = min(ans , s)

print(ans)
# Judge status: Accepted
a=int(input())

odd = 0

for i in range(1, a+1):
    if i%2==1:
        odd += 1

print('{:.10f}'.format(odd/a))
# Judge status: Accepted
#   AtCoder abc067 a
#   ストレッチ課題

#   入力
a, b = map(int, input().split())

#   判定
if (a % 3 == 0) or (b % 3 == 0) or ((a + b) % 3 == 0):
    print("Possible")
else:
    print("Impossible")
# Judge status: Accepted
a,b,c = map(int,input().split())
x = sorted([a,b,c])
ans = "No"

if x[1] == c:
    ans = "Yes"
    
print(ans)
# Judge status: Accepted
a=int(input())
b=int(input())
c=int(input())
x=int(input())
ans=0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i*500+j*100+k*50==x:
                ans+=1
print(ans)
# Judge status: Wrong Answer
S=input()
h="hi"
for i in range(5):
  if h*i==S:
    print("Yes")
    break
else:
  print("No")
# Judge status: Accepted
s = str(input())
n = len(s)
ans = ""
for i in range(n):
    ans += "x"
print(ans)
# Judge status: Accepted
# coding: utf-8
# Your code here!

import collections
a = int(input())
li1 = []
 
for i in range(a):
    li1.append(str(input()))
 
c = collections.Counter(li1)
 
sorted_items = sorted(
  c.most_common(),
  key = lambda x:(x[1],x[0]), reverse=True)
 
key, value = zip(*sorted_items)
li2 = []
li2.append(key[0])
for i in range(1,len(key)):
    if(value[0] == value[i]):
        li2.append(key[i])
    else:
        break;

list.sort(li2)

for i in range(len(li2)):
    print(li2[i])
# Judge status: Accepted
N = int(input())
H = tuple(map(int, input().split()))

n_max = 0
n = 0
last = H[-1]
for x in H[-2::-1]:
    if x >= last:
        n += 1
    else:
        n_max = max(n, n_max)
        n = 0
    last = x
n_max = max(n, n_max)
print(n_max)
# Judge status: Accepted
def main():
    N,Y=map(int,input().split())

    for i in range(Y//10000+1):
        tY=Y-10000*i
        for j in range(tY//5000+1):
            k=(tY-5000*j)//1000
            if i+j+k==N:
                print(i,j,k)
                return

    print("-1 -1 -1")

main()
# Judge status: Accepted
import math

n, d = map(int, input().split())
ans = 0

for i in range(0, n):
  x, y = map(int, input().split())
  r = math.sqrt(x ** 2 + y ** 2)
  if r <= d:
    ans += 1

print(ans)
# Judge status: Accepted
S = input()
T = input()

n = 0

for s, t in zip(S, T):
    if s != t:
        n += 1

print(n)
exit()
# Judge status: Wrong Answer
s = input()
s_list = list(s)

def has_duplicates(seq):
    return len(seq) != len(set(seq))

if has_duplicates(s_list):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a,b=input().split()
a=int(a)
b=int(b)
if ((a+b)%3)==0:
  print("Possible")
else:
  if (a%3)==0:
    print("Possible")
  else:
    if (b%3)==0:
      print("Possible")
    else:
      print("Impossible")
# Judge status: Accepted
from collections import *
from itertools import *
from bisect import *
from heapq import *
import copy
import math
from fractions import gcd

mod=10**9+7
#N=int(input())
S=input()
Q=int(input())
Query=[list(input().split()) for i in range(Q)]


lst=deque(S)

flag=0
for query in Query:
    if len(query)==1:
        flag+=1
        flag%=2
    else:
        _,F,C=query
        if (int(F)+flag)%2:
            lst.appendleft(C)
        else:
            lst.append(C)

if flag:
    lst.reverse()
print("".join(lst))
# Judge status: Accepted
import sys

def main():
    A, B, C = map(int, input().split())
    ans = max(0, C - (A-B))
    print(ans)

    return


if __name__ == '__main__':
    main()
    sys.exit(0)
# Judge status: Wrong Answer
import bisect

N = int(input())
LIS = [-1 * int(input())]
for _ in range(N-1):
    A = -1 * int(input())
    if A >= LIS[-1]:
        LIS.append(A)
    else:
        LIS[bisect.bisect_left(LIS, A)] = A

print(len(LIS))
# Judge status: Wrong Answer
n, x, t = map(int, input().split())
print(((n//x)+1)*t)
# Judge status: Wrong Answer
A, B, C, X, Y = map(int, input().split())

ans = float('inf')

if A + B >= 2 * C:
    p = (2 * max(X, Y)) * C
    ans = min(ans, p)
else:
    for x in range(X + 1):
        for y in range(Y + 1):
            c = max(X - x, Y - y)
            p = x * A + y * B + (2 * c) * C
            ans = min(ans, p)

print(ans)
# Judge status: Accepted
h,n = map(int, input().split())

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

if sum(a) >= h:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer

url = "https://atcoder.jp//contests/abc113/tasks/abc113_b"

def main():
    input()
    t, a = list(map(int, input().split()))
    syuto = list(map(int, input().split()))
    tempture = []
    for s in syuto:
        tempture.append((a - (t - s * 0.006)))
    print(tempture.index(min(tempture))+1)


if __name__ == '__main__':
    main()
# Judge status: Accepted
s = list(input())
ans = []
for i in s:
    if i == "B":
        if ans == []:
            pass
        else:
            del ans[-1]
    else:
        ans.append(i)
print("".join(ans))
# Judge status: Wrong Answer
P, Q, R = map(int ,input().split())
print(max(P+Q, Q+R, R+P))
# Judge status: Accepted
s = input()
t = input()
if s == t[:len(s)]:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
A, B, C = map(int, input().split())

flag = 0
for i in range(B):
  if A* i % B == C:
    flag = 1
    break
    
if(flag == 1):
  print("YES")
else:
  print("NO")
# Judge status: Accepted
def main():
    X, Y = map(int, input().split())
    
    ans = 0
    while X <= Y:
        ans += 1
        X *= 2
    print(ans) 

if __name__ == "__main__":
    main()
# Judge status: Accepted
a,b,c = map(int,input().split())
if c >= a and c <= b:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n,r = list(map(int,(input().split())))
if n<=10:
  naibu =(100*(10-n))
  print(r+naibu)
else:
  print(r)
# Judge status: Accepted
n,y = [int(e) for e in input().split()]
for i in range(0,n+1):
    for j in range(0,n-i+1):
        if 10000*i + 5000*j + 1000*(n-i-j) == y:
            print(str(i)+" " +str(j) + " " + str(n-i-j))
            break
    else:
        continue
    break
else:
    print("-1 -1 -1")
# Judge status: Accepted
N,Q = map(int, input().split())
S = input()
Query = []
for _ in range(Q):
    l,r = map(int, input().split())
    Query.append([l,r])

A = [0]*N

for i in range(N-2+1):
    if S[i]=="A" and S[i+1]=="C":
        A[i] = 1
s = [0]*(N+1)
for i in range(0,N,1):
    s[i+1] = A[i] + s[i]

for i in range(Q):
    l,r = Query[i]
    print(s[r-1]-s[l-1])
# Judge status: Accepted
n = input()
s = str(n)
l = len(s)
ans = 0
for i in range(l+1):
    ans += int(s[-i]) 
p = ans-(int(s[-l]))
if p%9 == 0:
    print("Yes")
    exit()
print("No")
# Judge status: Wrong Answer
k,n = map(int,input().split())
num_list = list(map(int, input().split()))
min_num = num_list[0]+num_list[-1]

for i in range(0,len(num_list)):
    res = num_list[-1]-k
    #print(num_list)
    num_list.pop(-1)
    #print(num_list)
    num_list.insert(0, res)
    #print(num_list)
    sum_num = abs(num_list[0])+abs(num_list[-1])
    #print("sum_num")
    #print(sum_num)
    
    if sum_num < min_num:
        min_num = sum_num

print(min_num)
# Judge status: Accepted
n=int(input())
d={2:0}
while n%2<1:  n//=2;  d[2]+=1
for i in range(3,int(n**0.5)+1,2):
  while n%i<1:  n//=i;  d[i]=d.get(i,0)+1
  if n<2: break
if n>1: d[n]=1
a=0
for i in d.values():
  t=c=0
  while t+c<i: c+=1; t+=c
  a+=c
print(a)
# Judge status: Wrong Answer
# 169A

# 1.入力をちゃんと受け取る。図解をする
# ex: [2 5] a=2 b=5 的な

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

print(a)
print(b)

# 2.計算
answer=a*b

# ３出力
print(answer)
# Judge status: Accepted
n = int(input())
arr = list(map(int, input().split()))
sum1 = 0
sum2 = sum(arr)
min_ = 1<<60

for i in range(n-1):
    sum1 += arr[i]
    sum2 -= arr[i]
    min_ = min(min_, abs(sum1 - sum2))
print(min_)
# Judge status: Accepted
A=input()

for i in range(2**3):
  tmp=['-','-','-']
  for j in range(3):
    if ((i>>j)&1):
      tmp[j]='+'
  if eval(A[0]+tmp[0]+A[1]+tmp[1]+A[2]+tmp[2]+A[3])==7:
    print(A[0]+tmp[0]+A[1]+tmp[1]+A[2]+tmp[2]+A[3]+"=7")
    exit()
# Judge status: Wrong Answer
n = int(input())

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

import collections

c = collections.Counter(al)

res = 0
for i in range(1,n+1):
    if c[i] ==0:
        pass
    elif c[i] ==i:
        pass
    else:
        if c[i] >i:
            res += c[i]-i
        else :
            res +=c[i]
    
print(res)
# Judge status: Accepted
x = int(input())
res = 10 - x // 200
print(res)
# Judge status: Wrong Answer
A, B, C, D, E = map(int, input().split())

result = 15 - (A+B+C+D+E)
# Judge status: Accepted
def resolve():
    N, M = map(int, input().split())

    start_index = 1
    last_index = N
    for _ in range(M):
        pp, ss = map(int, input().split())
        start_index = max(start_index, pp)
        last_index = min(last_index, ss)

    print(max(0, last_index - start_index + 1))


resolve()
# Judge status: Wrong Answer
S = int(input())
M = 0
div = S//3
res = S%3
ans = 0

while div - M > 0:
  ans_tmp = ((div - M)**(res+3*M))%(10**9+7)
  ans += ans_tmp
  M += 1
print(ans%(10**9+7))
# Judge status: Accepted
r, g, b = map(int, input().split())
if (100 * r + 10 * g + b) % 4:
    print("NO")
else:
    print("YES")
# Judge status: Accepted
S = input()

t = list(sorted(list(set(chr(i) for i in range(ord('a'), ord('z') + 1)) - set(S))))
if len(t) == 0:
    print('None')
else:
    print(t[0])
# Judge status: Accepted
N = int(input())
A = input().split()
num_list = [0] * 10**5
ans = 0

for i in range(N):
    num_list[int(A[i])-1] += 1

for i in range(10**5):
    ans += (i+1) * num_list[i]

Q = int(input())

for i in range(Q):
    B, C = map(int, input().split())

    ans = ans + C * num_list[B-1] - B * num_list[B-1]
    num_list[C-1] += num_list[B-1]
    num_list[B-1] = 0

    print(ans)
# Judge status: Accepted
import string
import sys
s = str(input())
low = string.ascii_lowercase
fin = ''
for i in range(len(low)):
    if low[i] not in s:
        print(low[i])
        sys.exit()
print('None')
# Judge status: Accepted
n=int(input())
s=input()
l=[]
counter=0
for i in range(n):
    if s[i]=="(":
        counter+=1
    else:
        counter-=1
    l.append(counter)
suml=l[-1]
for i in range(n):
    if l[i]<0:
        s="("+s
        for j in range(n):
            l[j]+=1
        suml+=1
if suml>0:
    s+=")"*suml
print(s)
# Judge status: Wrong Answer
a,b,x=map(int,input().split())
if x>=a and a+b>=x:
  print('YEs')
else:
  print('NO')
# Judge status: Accepted
N, K = map(int, input().split())
A = []

for i in range(K):
    d = int(input())
    A.append(list(map(int, input().split())))

s = set()
for i in range(K):
    for a in A[i]:
        s.add(a)

# print(s)
print(N - len(s))
# Judge status: Accepted
str = input()
if str.isupper():
    print("A")
elif str.islower():
    print("a")
# Judge status: Wrong Answer
a = 1
for i in range(int(input()),1):
    a = a * i % 1000000007
print(a)
# Judge status: Wrong Answer
from math import ceil

n,h=map(int,input().split())
a=[]
b=[]
ans=0

for i in range(n):
  aa,bb=map(int,input().split())
  a.append(aa)
  b.append(bb)

b.sort()
b.reverse()

pin=max(a)

for i in range(n):
  p=b[i]
  if p<=pin:
    break
  ans+=1
  h-=p


ans+=ceil((h-0.5)/pin)


print(ans)
# Judge status: Accepted
N=int(input())
print(int(N**(1/2))**2)
# Judge status: Wrong Answer

N = int(input())
A = [int(input()) for _ in range(N)]

res = 0
b = 0

for a in A:
    res += a//2
    a %= 2
    if a+b == 2:
        res += 1
        b = 0
    else:
        b = a

print(res)
# Judge status: Accepted
n = str(input())[::-1]
n = n + "0"
l = len(n)
ans = 0
flg = 0
check = 0

for i in range(l):
    check = int(n[i])
    check += flg
    if check == 5:
        if int(n[i + 1]) >= 5:
            ans += 5
            flg = 1
        else:
            ans += 5
            flg = 0
    elif check > 5:
        ans += 10 - check
        flg = 1
    else:
        ans += check
        flg = 0
print(ans + flg)
# Judge status: Wrong Answer
N,S = map(int,input().split())
n,s = map(int,input().split())
T = int(input())

ans1 = N + S*T
ans2 = n + s*T

if S - s <= 0 or n < N:
  print("NO")
elif ans1 >= ans2 and (n-N) % (S-s) == 0:
  print("YES")
else:
  print("NO")
# Judge status: Accepted
A,B,m=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
tmp=min(a)+min(b)
for i in range(m):
    x,y,c=map(int,input().split())
    if a[x-1]+b[y-1]-c<tmp:
        tmp=a[x-1]+b[y-1]-c
print(tmp)
# Judge status: Accepted
from itertools import combinations_with_replacement
n,m,q=map(int,input().split())
l=[list(map(int,input().split())) for i in range(q)]
ans=0
for i in combinations_with_replacement([i for i in range(1,m+1)], n):
    tmp=0
    for a,b,c,d in l:
        if i[b-1]-i[a-1]==c:
            tmp+=d
    ans=max(ans,tmp)
print(ans)
# Judge status: Accepted
o=list(input())
e=list(input()+" ")
for x,y in zip(o,e):
    print((x+y),end="")
# Judge status: Accepted
n = int(input())
ab = sorted([list(map(int, input().split())) for _ in range(n)], key=lambda x: x[1])

current = 0
for a, b in ab:
    current += a
    if current > b:
        print("No")
        exit()
print("Yes")
# Judge status: Wrong Answer
n,k=map(int,input().split())

if k==1:
    print(0)
elif n>k:
    print(k-(n%k))
else:
    print(k-(n%k))
# Judge status: Accepted
P=list(map(int,input().split()))

Q=sorted(P)

print(Q[0]+Q[1])
# Judge status: Accepted
def dist(s1,s2):
  return abs(s1[1]-s2[1]) + abs(s1[2]-s2[2])

N=int(input())
now = (0,0,0)
for i in range(N):
  next_ = list(map(int,input().split()))
  if dist(now,next_)<=next_[0]-now[0] and dist(now,next_) % 2 == (next_[0]-now[0])%2:
    now = next_
    continue
  else:
    print('No')
    exit()
print('Yes')
# Judge status: Wrong Answer
n,k,s=map(int,input().split())
ans=[]
for i in range(k):
  ans.append(s)
for i in range(n-k):
  ans.append(0)

print(*ans)
# Judge status: Accepted
N = int(input())
S = list(input())
ans = 0
for i in range(N):
    a = S[:i]
    b = S[i:]
    aset = set(a)
    bset = set(b)
    count = 0
    for i in aset:
        if i in bset:
            count += 1
    ans = max(ans,count)
print(ans)
# Judge status: Wrong Answer
import numpy as np
n = int(input())
a = np.array([int(i) for i in input().split()])
if np.prod(a) >= 0:
    print(int(np.abs(a).sum()))
else:
    m = np.abs(a).min()
    print(int(np.abs(a).sum() - 2 * m))
# Judge status: Accepted
N = int(input())
ryuka = [0]*(N+1)
ryuka[0] = 2
ryuka[1] = 1
for i in range(2, N+1):
    ryuka[i] = ryuka[i-1]+ryuka[i-2]
print(ryuka[-1])
# Judge status: Wrong Answer
a,b,x = map(int,input().split())
import numpy as np
if x<=(a*a*b)/2:
    A = 2*x/(a*b*b)
    Z = A
    print(a)
    print(90-np.arctan(Z)*180/(np.pi))
else:
    A = 2*a*a*b-2*x
    B = A/(a*a*a)
    Z = B
    print(np.arctan(Z)*180/np.pi)
# Judge status: Accepted
a, b, k = map(int, input().split())
m = min(a, b)

div = []
for i in range(1, m+1):
    if a % i == 0 and b % i == 0:
        div.append(i)
div.reverse()
print(div[k-1])
# Judge status: Accepted
N, M = list(map(int, input().split()))
A = {i: 0 for i in range(N+1)}
mod = 10 ** 9 + 7
for _ in range(M):
    A[int(input())] = 1

dp = [0 for _ in range(N+1)]
dp[0] = 1

for i in range(N+1):
    if A.get(i+1) == 0:
        dp[i + 1] += dp[i]
    if A.get(i+2) == 0:
        dp[i + 2] += dp[i]

print(dp[N]%mod)
# Judge status: Accepted
import math
# import bisect
import sys
# from collections import Counter
input = sys.stdin.readline
def inp():
	return(int(input()))
def inlt():
	return(list(map(int,input().split())))
def insr():
	s = input()
	return(s[:len(s)-1])
def invr():
	return(map(int,input().split()))
def print_fract(p,q):
	g = math.gcd(p,q)
	p//=g
	q//=g
	print(str(p)+"/"+str(q))
# list1, list2 = zip(*sorted(zip(list1, list2)))
N, D = invr()
out  = 0
for n in range(N):
	X, Y = invr()
	if ((X**2)+(Y**2))**0.5 <= D:
		out += 1
print(out)
# Judge status: Accepted
a,b,c=map(int,input().strip().split(" "))
k=max(a,b,c)
print(9*k+a+b+c)
# Judge status: Wrong Answer
n = int(input())
A = list(map(int, input().split()))

c = 1
res = 0
for a in A :
    if c == a :
        c += 1
    else :
        res += 1

print(res)
# Judge status: Accepted
n1=[1,3,5,7,8,10,12]
n2=[4,6,9,11]
a,b=map(int,input().split())
print("Yes" if (a in n1 and b in n1) or (a in n2 and b in n2) or (a == 2 and b == 2) else "No")
# Judge status: Accepted
List =  list(map(int, input().split()))
K = int(input())
sort = sorted(List)
for i in range(K):
    sort[-1] = sort[-1]*2
print(sum(sort))
# Judge status: Accepted
N, K = map(int, input().split())

list = list(range(N+1))
t = 10**9+7
result = 0

for i in range(K,N+2):
    result +=  i*(N-i+1) + 1

print(result%t)
# Judge status: Accepted
K = int(input())
Q = 0
A = 0
for i in range(1,K+1):
  if i % 2 == 0:
    Q += 1
  else:
    A += 1
print(Q*A)
# Judge status: Wrong Answer
n = int(input())
cs = 'abcdefghijklmn'
cm = {cs[i]:i for i in range(len(cs))}

def rec(string, l):
    if (l >= n):
        print(string)
        return 0
    now = string[-1]
    k = max(cm[string[i]]+1 for i in range(len(string)))
    k = max(k, cm[now] + 2)
    for c in cs[:k]:
        rec(string + c,l+1)

rec('a',1)
# Judge status: Accepted
import heapq

n,m=map(int,input().split())
X=[[] for _ in range(10**5+5)]
for i in range(n):
    a,b=map(int,input().split())
    X[a-1].append(-b)

ans=0
p=[]
heapq.heapify(p)
for i in range(m):
    if len(p)==0 and len(X[i])==0:
        continue
    for j in range(len(X[i])):
        heapq.heappush(p,X[i][j])
    a=heapq.heappop(p)
    ans+=a*-1
print(ans)
# Judge status: Wrong Answer
n=input()
n=int(n)
og=n
flag=0
while(n>0):
    d=n%10
    n=n//10
    if(d==7):
        flag=flag+1
        
if(flag>0):
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
a, W, b = map(int,input().split())
if a <= b:
    print(max(0,b-(a+W)))
elif a > b:
    print(max(0,(a-b)))
# Judge status: Accepted
a,b = map(int,input().split())
if a <= b:
	print(a)
else:
	print(a-1)
# Judge status: Accepted
sx, sy, tx, ty = map(int, input().split())

p1 = 'U' * (ty - sy) + 'R' * (tx - sx)
p2 = 'U' + 'L' * (tx - sx + 1) + 'D' * (ty - sy + 1) + 'R'
p3 = p1[::-1]
p4 = p2[::-1]

print(p1 + p2 + p3 + p4)
# Judge status: Accepted
N,M=map(int,input().split())
ans=[]

if N%2==0:
    N-=1

half=N//2

if half%2==0:
    for i in range(half//2):
        ans.append((i+1,half-i))
    for j in range(half//2):
        ans.append((half+1+j,N-j))
else:
    for i in range(half//2):
        ans.append((i+1,half-i))
    for j in range(half//2+1):
        ans.append((half+1+j,N-j))

#print(ans)
for i in range(M):
    print(*ans[i])
# Judge status: Accepted
st = input()
tl = 0
for s in st[:]:
  tl += int(s)
print(tl)
# Judge status: Wrong Answer
from itertools import combinations
n = int(input())
v = list(map(int, input().split()))
if len(set(v)) == 1:
    print(v[0])
elif len(set(v)) == 2:
   print(sum(list(set(v)))/2)
else:
    p = set(v)
    res = []
    s = list(combinations(p, 2))
    for i in s:
        a = sum(i)/2
        b = max(list(p-set(i)))
        res.append((a+b)/2)
    print(max(res))
# Judge status: Accepted
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    L, R, d = [int(x) for x in input().split()]
    print(R // d - (L - 1) //d)



if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
a,b,c=map(int,input().split())

if 4*a*b<(c-a-b)**2:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
k,x=[int(x) for x in input().split()]
a=500*k
if a>=x:
  print("Yes")
else:
  print("No")
# Judge status: Accepted

n, x, y = map(int, input().split())


d = [0]*(n-1)
for i in range(1, n):
    for j in range(i+1,n+1):
        c = min(j-i, abs(i-x)+1+abs(j-y))
        d[c-1] = d[c-1] + 1

for i in d:
    print(i)
# Judge status: Wrong Answer
x,y,z = map(int,input().split(' '))
tmp = x
x = y
y = tmp
tmp = x
x = z
z = tmp
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
def Csum(a):
    b,c=[0],0
    for i in range(len(a)):
        c+=a[i]
        b.append(c)
    return b
b=Csum(a)
c=sum(a)
d=[]
for i in range(1,n):
    d.append(abs((c-b[i])-b[i]))
print(min(d))
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)
print(max(sum(A[N:2*N]),sum(A[1:2*N:2])))
# Judge status: Wrong Answer
n,a,b = [int(x) for x in input().split()]

INF = (10**9 + 7)


if n == 2:
    print(0)
else:
    ans = (2 ** n -1) - (2**a - 1) - (2 ** b - 1)
    print(ans % INF)
# Judge status: Wrong Answer
N = int(input())
cnt_list = {}
for i in range(N):
  S = input()
  if S in cnt_list:
    cnt_list[S] += 1
  else:
    cnt_list[S] = 0

max_cnt = max(cnt_list.values())
res_list = []

for a in cnt_list.items():
  if a[1] == max_cnt:
    res_list.append(a[0])

res_list.sort()
print(res_list)
# Judge status: Wrong Answer
from fractions import gcd

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

cd_gcd = gcd(c, d)
cd_lcm = c * d // cd_gcd

ans = (b - a + 1) - (b - a -1)//c - (b - a -1)//d + (b - a -1)//cd_lcm
print(ans)
# Judge status: Accepted
from collections import defaultdict
N = int(input())
values = list(map(int, input().split()))
keys = list(range(1, N + 1))

memo = defaultdict(int)
count = 0
for i, x in enumerate(values):
    count += memo[i - x]
    memo[i + x] += 1
print(count)
# Judge status: Accepted
# coding: utf-8

# https://atcoder.jp/contests/abc119


def main():
    S = input()
    m = int(S[5:7])
    
    if m <= 4:
        return "Heisei"
    else:
        return "TBD"


print(main())
# Judge status: Wrong Answer
N, A, B = map(int, input().split())
S = input()
 
ok_count = 0
ok_fcount = 0
for i in range(N):
  if S[i] == 'a':
    if ok_count < A+B-1:
      print('Yes')
      ok_count +=1
      
    else:
      print('No')
      
  elif S[i] == 'b':
    if ok_count <= A+B-1 and ok_fcount <= B-1:
      print('Yes')
      ok_count+=1
      ok_fcount+=1
      
    else:
      print('No')
      
  else:
    print('No')
# Judge status: Accepted
x=int(input())
ans=1
a=int(100*(1.01)**ans)
while a<x:
  ans+=1
  a*=1.01
  a=int(a)
print(ans)
# Judge status: Accepted
A, B, K = map(int, input().split())
if A > K:
    print(A-K, B)
elif A+B > K:
    print(0, A+B-K)
else:
    print(0, 0)
# Judge status: Wrong Answer
n = int(input())
robos = []
for i in range(n):
    x,l = map(int,input().split())
    robos.append([x-l+1,x+l-1])

robos.sort(key= lambda x:x[1])
# print(robos)
edge = -10000000000
out = 0
for i in range(n):
    if robos[i][0] > edge:
        out += 1
        edge = robos[i][1]
    else:
        continue

print(out)
# Judge status: Accepted
S = input()
print("Yes" if S.count("hi")*2==len(S) else "No")
# Judge status: Accepted
S = list(input())
ans = "AC"

if S[0] != "A":
  ans = "WA"

if S[2:-1].count("C") != 1:
  ans = "WA"
else:
  S.pop(S[2:-1].index("C") + 2)

if not "".join(S[1:]).islower():
  ans = "WA"

print(ans)
# Judge status: Accepted
n = int(input())
s = list(input())

a = s.count('R')
b = s.count('G')
c = s.count('B')

ans = a * b * c

m = (n-1) // 2
ans = a * b * c
for d in range(1, n):
    if d * 2 >= n:
        break
    for i in range(n):
        if i + d * 2 >= n:
            break
        if s[i] != s[i+d] and s[i] != s[i+d*2] and s[i+d] != s[i+d*2]:
            ans -= 1

print(ans)
# Judge status: Wrong Answer
N=int(input())
X=list(map(int,input().split()))

sum=0
A=[]

for i in range(int(X[N-1]+5)):
    for j in range(N):
        sum+=(X[j]-i)**2
    A.append(sum)
    sum=0

print(min(A))
# Judge status: Accepted

[K, X] = list(map(int,input().split()))

min= X-K+1
max= X+K-1

out=[]
for i in range(min,max+1):
    out.append(i)

out = ' '.join(map(str,out))
print(out)