peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
import math
import sys
a,b,n = map(int, input().split())
ans=0
if n<b:
    ans=math.floor(a*n/b)-a*math.floor(n/b)
    print(ans)
    sys.exit()
else:
    for i in range(b,n+1):
        tmp=(math.floor(a*i/b))-a*(math.floor(i/b))
        if ans<tmp:
            ans=tmp
    print(ans)
    sys.exit()
# Judge status: Accepted
import sys
X = int(input())
if 1 <= X and X < 100:
    print("0")
    sys.exit()
i = 0
dp = [0]*(X+1)
dp[0] = 1
for i in range(100, X+1):
    for j in range(6):
        if dp[i-(100+j)] == 0:
            pass
        else:
            dp[i] = 1
print(dp[X])
# Judge status: Accepted
n=int(input())
k=int(input())
x=int(input())
y=int(input())

ans=0

for i in range(1,n+1):
    if i<=k:
        ans+=x
    else:
        ans+=y

print(ans)
# Judge status: Accepted
n,m = map(int,input().split())
s = list(map(int,input().split()))
a = []
for i in s:
  if i >= sum(s)/(4*m):
    a.append(i)
    
if len(a) >= m:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
a=sorted(list(map(int,[input()for i in range(5)])),key=lambda x:x%10)
if ''.join([str(i)[-1]for i in a])=='00000':print(sum(a));quit()
while str(a[0])[-1]=='0':
  a+=[a[0]]
  del a[0]
print(a)
print(sum([a[0]]+[10*(0--i//10)for i in a[1:]]))
# Judge status: Wrong Answer
N = int(input())
A = list(map(int,input().split()))

count = 0

for i in A:
    if i%2 == 0:
        if i%3 == 0 or i%5 == 0:
            count += 1
        else:
            count += 0
    else:
        count += 1


if int(count) == N:
    print("APROVED")
else:
    print("DENIED")
# Judge status: Accepted
n = int(input())
cnt = 0
i=1
for i in range(1,n):
    a=int((n-1)/i)
    cnt+=a
print(cnt)
# Judge status: Wrong Answer
from collections import Counter

n = int(input())
a = list(map(int,input().split()))
a_count = sorted(Counter(a).items(),reverse=True)
f = False
for k,v in a_count:
    if v >= 4:
        print (k*2)
        exit ()
    elif 2 <= v and v <= 3:
        if f:
            print (x*k)
            exit (0)
        else:
            x = k
            f = True
    else:
        pass
print (0)
# Judge status: Accepted
n = "keyence"
s = input()

for i in s:
    if n[0] == i:
        n = n[1:]
    else:
        break

for i in s[::-1]:
    if n == "":
        print("YES")
        exit()
    elif n[-1] == i:
        n = n[:-1]
    else:
        break

print("NO")
# Judge status: Accepted
N = int(input())
A = sorted(list(map(int, input().split())), reverse=True)

lengths = []
for i in range(len(A) - 1):
    try:
        if A[i] == A[i+3] and len(lengths) == 0:
            lengths.append(A[i])
            lengths.append(A[i])
            break
    except:
        pass

    if (A[i] not in lengths) and (A[i] == A[i+1]):
        lengths.append(A[i])

    if len(lengths) == 2:
        break

try:
    ans = lengths[0] * lengths[1]
except:
    ans = 0

print(ans)
# Judge status: Accepted
A,B,C=map(int,input().split())
if C-(A-B)>=0:
    print(C-(A-B))
else:
    print(0)
# Judge status: Wrong Answer
N,A,B = map(int,input().split())
print(N*B-N*A+1)
# Judge status: Accepted
n=int(input())

d=2
ans=0

while d*d <= n:
    if n%d != 0:
        d +=1
        continue

    z=d

    while n%z ==0:
        n //=z
        z *= d
        ans += 1
    
    while n % d == 0:
        n /= d

if n != 1:
    ans +=1

print(ans)
# Judge status: Accepted
# -*- coding: utf-8 -*-

from decimal import Decimal

a, b = input().split()

print(int(Decimal(a)*Decimal(b)))
# Judge status: Accepted
#ABC131
N,L = map(int,input().split())
f = 0
k = 0
j = []
for i in range(1,N+1):
    f += L+i-1
for i in range(1,N+1):
    k = L+i-1
    n = f-k
    p = abs(f-n)
    j.append(p)
if f >0:
    print(int(f-min(j)))
else:
    print(int(f+min(j)))
# Judge status: Wrong Answer
a, b = map(int, input().split())

print(a+b/2)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

ans = 0
for i in range(n):
    if ((i + 1) % 2 == 1 and a[i] % 2 == 1):
        ans += 1

print(ans)
# Judge status: Accepted
import fractions
N,X = map(int,input().split())
x = list(map(int,input().split()))
x.append(X)
b = list(sorted(x))
c = list()
for i in range(N):
    c.append(b[i+1]-b[i])

t = 0
for i in range(N):
    t = fractions.gcd(t, c[i])
print(t)
# Judge status: Wrong Answer
a,b=map(int,input().split())
if abs(a-b)*2<=a*2-16:
    print("Yay!")
else:
    print(":(")
# Judge status: Accepted
A, B = map(int, input().split())
ans = 0
for i in range(A, B+1):
   num_rev = list(reversed(list(map(int, str(i)))))
   if int(''.join(map(str, num_rev))) == i:
       ans += 1

print(ans)
# Judge status: Accepted
def main():
    N = int(input())
    A = list(map(int, input().split()))

    reslt = {}
    re = []

    for i, num in enumerate(A):
        reslt[num] = i + 1

    for k, v in sorted(reslt.items()):
        re.append(v)

    print(*re)


if __name__ == "__main__":
    main()
# Judge status: Accepted
a, b = map(int,input().split())

cnt = 0
num = a
while num<=b:
  cnt += 1
  num *= 2
  
print(cnt)
# Judge status: Accepted
x,y=map(int,input().split())

G = [0,1,3,1,2,1,2,1,1,2,1,2,1]

if G[x]==G[y]:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import numpy as np

s = input()
t = list("abcdefghijklmnopqrstuvwxyz")
s = list(sorted(set(s)))

ans = "None"
ls = len(s)
for i in range(ls):
    if s[i] != t[i]:
        ans = t[i]
        break
    elif s[i] == t[i] and i == ls-1 and i < 25:
        ans = t[i+1]
        break
        
print(ans)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

Sf = [A[0]]
for i in range(1, N):
  Sf.append(Sf[-1] + A[i])

A = A[::-1]
Sb = [A[0]]
for i in range(1, N):
  Sb.append(Sb[-1] + A[i])
Sb = Sb[::-1]

answer = 10 ** 15
for i in range(N - 1):
  answer = min(answer, abs(Sf[i] - Sb[i + 1]))
  
print(answer)
# Judge status: Accepted
import sys
import math

def input():
    return sys.stdin.readline().rstrip()


def main():
    A,B=map(int,input().split())
    
    if (A + B) %2 ==0:
        print(int(A/2+B/2))
    else:
        print("IMPOSSIBLE")
    



if __name__ == "__main__":
    main()
# Judge status: Accepted
from itertools import accumulate, permutations

import bisect
# ----------

INF = float("inf")
MOD = 10 ** 9 + 7
# ----------

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

A = [0] + list(accumulate(A))
B = [0] + list(accumulate(B))

ans = 0
for i in range(N+1):
    a = A[i]
    if a > K:
        break
    r = K - a
    j = bisect.bisect(B, r) - 1
    ans = max(ans, i + j)

print(ans)
# Judge status: Accepted
list_num = list(map(int, input().split(' ')))

if int(str(list_num[0])*list_num[1]) > int(str(list_num[1])*list_num[0]):
    print(int(str(list_num[0]) * list_num[1]))
else:
    print(int(str(list_num[1]) * list_num[0]))
# Judge status: Wrong Answer
N = int(input())
h = list(map(int, input().split()))

DP = [0 for _ in range(N)]
DP[0] = 0
DP[1] = h[1]-h[0]

for i in range(2, N):
    DP[i] = min(DP[i-1]+abs(h[i-1]-h[i]), DP[i-2]+abs(h[i-2]-h[i]))
#print(DP)
print(DP[N-1])
# Judge status: Wrong Answer
N,w = [int(x) for x in input().split()]
ll = []
for i in range(N):
    abc = [int(x) for x in input().split()]
    ll.append(abc)
DP = [[0]*(w+1) for i in range(N+1)]
for i in range(1,N+1):
    for j in range(1,w+1):
        if ll[i-1][0] <= j:
            DP[i][j] = max(DP[i-1][j-ll[i-1][0]]+ll[i-1][1],DP[i-1][j])
        else:
            DP[i][j] = DP[i-1][j]
print(DP)
# Judge status: Wrong Answer
s=input()
n=len(s)
count=0
for i in range(n):
  for j in range(i+4,n):
    if int(s[i:j])%2019==0:
      count+=1
print(count)
# Judge status: Accepted
x, k, d = map(int, input().split())
x = abs(x)
a = x//d
k2 = k-a
if x-k*d > 0:
    print(x-k*d)
    exit()

if k2%2 == 0:
    print(x%d)
else:
    print(abs(x%d-d))
# Judge status: Accepted
# Battle
ln = list(map(int, input().split(' ')))
thp = ln[0]
tatk = ln[1]
ahp = ln[2]
aatk = ln[3]
turn = 0
while thp>0 and ahp>0:
    if turn %2 == 0:
        ahp -= tatk
        turn += 1
    else:
        thp -= aatk
        turn += 1

if thp>0:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))

MAX=max(a)
Harf=MAX/2

cnt=10**20
ans=0
for i in range(n):
    if MAX==a[i]:
        continue
    elif abs(Harf-a[i])<cnt:
        ans=a[i]
        cnt=abs(Harf-a[i])
print(MAX,ans)
# Judge status: Accepted
n = int(input())
xs = [int(i) for i in input().split()]
length = len(xs)
count = 0

while True:
  xs = [x // 2 for x in xs if x % 2 == 0]
  
  if length == len(xs):
    count += 1
  else:
    break
    
print(count)
# Judge status: Accepted
N = int(input())
P = list(map(int, input().split()))
k=P[0]
ans=0
for i in range(N):
    if (k>=P[i]):
        ans+=1
        k=P[i]
print(ans)
# Judge status: Wrong Answer
N = int(input())
z = []
for _ in range(N):
  x, y = list(map(int, input().split()))
  z.append([x, y])

z.sort()
mdct = 0
lx, ly = z[0]
rx, ry = z[N-1]
z.sort(key=lambda x: x[1])
sx, sy = z[0]
ux, uy = z[N-1]
for xa, ya in [[lx, ly], [rx, ry]]:
  for xb, yb in [[sx, sy], [ux, uy]]:
    mdct = max(mdct, abs(xa - xb) + abs(ya - yb))

print(mdct)
# Judge status: Accepted
def operation(a,ops):
    ans = a[0]
    for i in range(3):
        if ops[i]=='+':
            ans += a[i+1]
        else:
            ans -= a[i+1]
    return ans

s = list(input())
a = [int(i) for i in s]
op = ['+','-']

for i in range(1<<3):
    ops = [op[1&(i>>j)] for j in range(3)]
    if operation(a,ops)==7:
        print("{}{}{}{}{}{}{}=7".format(a[0],ops[0],a[1],ops[1],a[2],ops[2],a[3]))
        break
# Judge status: Wrong Answer
a, b = map(float, input().split())

b = int(b*100)

print(int(a*b//100))
# Judge status: Accepted
N, x = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
ans = 0
for i in range(len(A)):
    x = x-A[i]
    if x >= 0:
        ans += 1
    else:
        break
if x > 0:
    ans -= 1
print(ans)
# Judge status: Wrong Answer
from copy import deepcopy
import numpy as np


nk = input().split()
n = int(nk[0])
k = int(nk[1])
ajs = input().split()
ajs = np.array([int(aj) for aj in ajs])

ak_current = ajs[:k].cumprod()[-1]

for i in range(k, n):
  ak_tmp = deepcopy(ak_current)

  ak_tmp =  ak_tmp / int(ajs[i-k]) * int(ajs[i])
  
  if ak_tmp > ak_current:
    print('Yes')
  else:
    print('No')
    
  ak_current = ak_tmp
# Judge status: Accepted
n = int(input())
l = list(map(int,input().split()))
if max(l)< sum(l)-max(l):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import sys
import collections

N = int(input())
Ans = 111

while True:
    if len(collections.Counter(list(str(Ans)))) == 1 and Ans >=  N:
        print(Ans)
        sys.exit()
    else:
        Ans += 1
# Judge status: Accepted
N, M, K = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]
B = [int(_) for _ in input().split()]

v = 0
for i in range(N):
    if v + A[i] <= K:
        v += A[i]
    else:
        mi = i-1
        break
else:
    mi = N-1

ans = mi+1

for j in range(M):
    while mi > -1 and v + B[j] > K:
        v -= A[mi]
        mi -= 1
    v += B[j]
    if v <= K:
        ans = max(ans, mi+1+ j+1)

print(ans)
# Judge status: Accepted
s, t = map(str, input().split())
a, b = map(int, input().split())
u = input()
if u == s:
    a -= 1
elif u == t:
    b -= 1
print(a, b)
# Judge status: Accepted
n, m = map(int, input().split())
if n == m == 1:
    print(1)
elif n == 1 or m == 1:
    print(max(n, m) - 2)
else:
    print((n - 2) * (m - 2))
# Judge status: Accepted
def solve():
    ans = 0
    N = int(input())
    for i in range(1,N+1):
        ans += i*(1+N//i)*(N//i)//2
    return ans
print(solve())
# Judge status: Accepted
s = input()
if s == "a" or s == "i" or s == "u" or s == "e" or s == "o":
	print("vowel")
else:
	print("consonant")
# Judge status: Accepted
D, N = map(int, input().split())
if (N == 100):
    print((N * (100 ** D)) + 100**D)
else:
    print(N * (100 ** D))
# Judge status: Accepted
x ,n = map(int,input().split())
p = list(map(int,input().split()))

for i in range(100):
    num = x - i
    if num not in p:
        print(num)
        exit()
    num = x + i
    if num not in p:
        print(num)
        exit()
# Judge status: Accepted

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

R=1
if 0 in A:
    print("0")
else:
    for i in range(0, N):
        R=R*A[i]
        if R>1000000000000000000:
            print("-1")
            exit()
        
    print(R)
# Judge status: Accepted
a,b,c,x,y = map(int, input().split())

if a+b <= c*2:
  print(a*x+b*y)
else:
  if x == y: print(c*x*2)
  elif x > y: 
    if a <= c*2: print(c*y*2+a*(x-y))
    else: print(c*x*2)
  elif x < y: 
    if b <= c*2: print(c*x*2+b*(y-x))
    else: print(c*y*2)
# Judge status: Wrong Answer
n, m = map(int, input().split())
if n > 2 and m > 2:
  ans = (n-2)*(m-2)
elif n == 2 or m == 2:
  ans = 0
elif n == 1:
  ans = m - 2
elif m == 1:
  ans = n - 2

print(ans)
# Judge status: Wrong Answer
a,b = map(str,input().split())
c=a*int(b)
d=b*int(b)
print(min(c,d))
# Judge status: Accepted
n = input()
pon = ['0','1','6','8']
last = n[-1]
if last == '3':
  print('bon')
elif last in pon:
  print('pon')
else:
  print('hon')
# Judge status: Accepted
n, x = map(int, input().split())
a = list(map(int, input().split()))
s = 0
t = 1
for i in range(n):
  s = s + a[i]
  if s <= x:
    t += 1
print(t)
# Judge status: Wrong Answer
n = int(input())
ans = 0

if 1 <= n and n < 99:
    ans = min(n, 9)
elif 100 <= n and n < 9999:
    ans = min(n-90, 909)
else:
    ans = min(n-9090, 90909)

print(ans)
# Judge status: Accepted
a, b, c, d = map(int, input().split())

if b < 0:
    if c <= 0:
        print(a * c)
    else:
        print(b * c)

elif a <= 0:
    if d < 0:
        print(a*c)
    elif a <= 0:
        print(max(a*c, b*d))
    else:
        print(b*d)

else:
    if d < 0:
        print(a * d)
    else:
        print(b * d)
# Judge status: Accepted
import collections
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
M=collections.Counter(A)
ans=0
for j in M.items():
  ans+=j[0]*j[1]
for i in range(Q):
  B,C=map(int,input().split())
  ans+=(C-B)*M[B]
  M[C]+=M[B]
  M[B]=0
  print(ans)
# Judge status: Accepted
n = int(input())
num = list(map(int, input().split()))
sorted_num = sorted([num[i-1]-i for i in range(1, n+1)])

b = sorted_num[n//2]
print(sum([abs(b-i) for i in sorted_num]))
# Judge status: Accepted
n=int(input())
b=list(map(int,input().split()))
a = [0] * n
a[0] = b[0]
a[n-1] = b[n-2]
for i in range(1, n-1):
    a[i] = min(b[i-1],b[i])
print(sum(a))
# Judge status: Accepted
s = input()
flag = False

if s[0]=="A":
	if s[2:-1].count("C")==1:
		if (s[1:s.index("C")].islower() and s[s.index("C")+1:].islower()):
			flag = True
print("AC" if flag else "WA")
# Judge status: Accepted
n=int(input())
t,a=map(int,input().split())
l=[]
h=map(int,input().split())
for i in h:
    l.append(abs(a-(t-i*0.006)))

print(l.index(min(l))+1)
# Judge status: Accepted
n=int(input())

A=[0]+list(map(int,input().split()))

for i in reversed(range(1,n+1)):
    if sum(A[::i])%2!=A[i]:
        if A[i]==0:
            A[i]=1
        else:
            A[i]=0
        
print(sum(A))
if sum(A)!=0:
    for i,a in enumerate(A):
        if a==1:
            print(i)
# Judge status: Wrong Answer
#K番目に"大きいもの"なのでおおきいものから調べないといけない

A, B , K = map(int, input().split())

ans = 1
counter = 0

for i in range(min(A,B), 0 , -1):
    if A % i == 0 and B % i == 0:
        counter += 1
        ans = i
    
    if counter == K:
        break

print(ans)
# Judge status: Accepted
N = int(input())
H = [int(i) for i in input().split()]

dp = [0] * (N+1)
dp[1] = abs(H[1] - H[0])

for i in range(2, N):
    dp[i] = min(dp[i-1] + abs(H[i]-H[i-1]), dp[i-2] + abs(H[i]-H[i-2]))

print(dp[N-1])
# Judge status: Accepted
#!/usr/bin python3
# -*- coding: utf-8 -*-

from bisect import bisect_left

N = int(input())
A = []
for _ in range(N):
    x = int(input())
    idx = bisect_left(A, x)
    if idx == 0:
        A.insert(idx, x)
    elif A[idx-1] == x:
        A.insert(idx, x)
    else:
        A[idx-1] = x
#    print(A,x)
print(len(A))
# Judge status: Accepted
import math
from functools import reduce

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

n = int(input())
t = [int(input()) for _ in range(n)]
print(lcm(*t))
# Judge status: Wrong Answer
s = input()
t = input()

go = []
back = []
def has_duplicates(seq):
    return len(seq) != len(set(seq))


for i in range(len(s)):
  go.append(s[i])
  back.append(t[i])
  
ansg = has_duplicates(go)
ansb = has_duplicates(back)

if ansg == True or ansb == True:
  print("No")
else:
  print("Yes")
# Judge status: Accepted
import numpy as np
N = int(input())
X = np.array(list(map(int,input().split(" "))))

energy = np.sum((X - X[0])**2)

X_max,X_min = np.max(X),np.min(X)
for i in range(X_min,X_max):
    energy_sum = np.sum((X-i)**2)
    if energy > energy_sum:
        energy = energy_sum

print(energy)
# Judge status: Wrong Answer
s = input()
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
alpha_rem = alpha.strip("AZ")

print(len(s.strip(alpha_rem)))
# Judge status: Accepted
s=input()
print('Heisei' if eval(s.replace('/','')+'<=20190430') else 'TBD')
# Judge status: Accepted
n = int(input())
a = input().split()
b = input().split()
c = input().split()
result = 0
for i in range(n):
    order = int(a[i]) - 1
    result += int(b[order])
    if int(a[i]) - int(a[i-1]) == 1 and i is not 0:
        result += int(c[order-1])
print(result)
# Judge status: Wrong Answer
n,k = map(int,input().split())
d = int(input())
print(n-d)
# Judge status: Wrong Answer
# 問題：https://atcoder.jp/contests/abc138/tasks/abc138_c

n = int(input())
v = list(map(int, input().strip().split()))
v.sort(reverse=True)
res = 0
for i in range(n-1):
    res += v[i] / (2**(i+1))
res += v[-1] / (2**(n-1))

print(v)
print(res)
# Judge status: Accepted
#!/usr/bin/env python3
n = int(input())
s = input()
white = sum([1 for i in s if i == "."])
ans = white#全部黒にするとき
l = 0 # i までのwhiteの数
for i in range(n):
    if s[i] == ".": l += 1
    #print(ans,i+white-2*l)
    ans = min(ans,i+1+white-2*l)
print(ans)
# Judge status: Accepted
a, b, t = map(int,input().split())
print(int((t+0.5)//a*b))
# Judge status: Accepted
a, b, c = map(int, input().split())

d1 = b - a
d2 = c - b

if (d1 == d2):
    print("YES")

else:
    print("NO")
# Judge status: Accepted
import sys
n, m = map(int, sys.stdin.readline().split())
a=[sys.stdin.readline().split() for i in range(m)]
wa = [0 for i in range(n)]
ac = [0 for i in range(n)]

for i in range(m):
    p = int(a[i][0])-1
    s = a[i][1]
    if s=="WA" and ac[p]==0:
        wa[p] +=1
        #print(wa, 'wa')
    elif s=="AC":
        ac[p] = 1
        #print(ac, 'ac')

cnt=0
for i in range(n):
    if ac[i]==1:
        cnt += wa[i]
print(sum(ac), cnt)
# Judge status: Wrong Answer
n,c,k = map(int,input().split())
t = []
ans = 0
lastbus = [0,c]
for i in range(n):
    t.append(int(input()))

t.sort()

for i in t:
    if lastbus[0] <= i:
        ans += 1
        lastbus[0] = i+c
        lastbus[1] = c-1
    else:
        if lastbus[1] == 0:
            ans += 1
            lastbus[0] = i+c
            lastbus[1] = c-1
        else:
            lastbus[1] -= 1
print(ans)
# Judge status: Wrong Answer
x,y = map(int,input().split())
if y%2==0 and x*4 >=y:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n = int(input())

def solve(n):
    if n % 2 != 0:
        return 0
    div = 10
    sol = 0
    term = n // div
    while term > 0:
        term = n // div
        sol += term 
        div *= 5
    return sol

print(solve(n))
# Judge status: Wrong Answer
string = str(input())
if ( (string[0]=='A' or string[1]=='A' and string[2]=='A') and (string[0]=='B' or string[1]=='B' and string[2]=='B')):
	print('Yes')
else:
	print('No')
# Judge status: Accepted
Key_str = 7

S = str(input())
count =0

if len(S)<Key_str:
    print("No")

else:
    del_str = len(S)-Key_str
    
    for i in range(len(S)-del_str):
        try_str = S[:i] + S[i+del_str:]
        if try_str == 'keyence':
            print("YES")
            count+=1
            break
    if count==0:
        print("NO")
# Judge status: Accepted
n,k = map(int,input().split())

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

print(-(-(n-1)//(k-1)))
# Judge status: Accepted
N = int(input())
B = list(map(int,input().split()))
ans = 0

for i in range(N):
    if i == 0:
        ans += B[0]
    elif i == N-1:
        ans += B[-1]
    else:
        ans += min(B[i-1],B[i])
print(ans)
# Judge status: Accepted
from fractions import gcd
n = int(input())
a = list(map(int,input().split()))
b = a[::-1]
ai = [a[0]]
bi = [b[0]]
for i in range(1, n):
    ai.append(gcd(ai[i-1], a[i]))
    bi.append(gcd(bi[i-1], b[i]))
ans = max(ai[n-2], bi[n-2])
for i in range(1, n-1):
    ans = max(gcd(ai[i-1], bi[n-i-2]), ans)
print(ans)
# Judge status: Wrong Answer
A, B = map(int, input().split())
p = input()
a, b = p[:A], p[A+1:]
print('Yes' if p[A] == '-' and (a + b).isdecimal else 'No')
# Judge status: Wrong Answer
x = list(map(lambda i: int(i), input().split(' ')))
all = x[0]
available = x[1]
time = x[2]

result = (all/available) * time
if all%available != 0:
    result += time 

print(int(result))
# Judge status: Wrong Answer
N = int(input())

print(N * (N+1)/2)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
a.sort()
dp = [0]*(1000000+1)
cnt = 0
for i in range(len(a)):
  if dp[a[i]]==1:
    continue
  j = 2
  while(a[i]*j<=a[-1]):
    dp[a[i]*j] = 1
    j += 1
  if i!=len(a)-1 and a[i+1]==a[i]:
    dp[a[i]] = 1
    continue
  cnt += 1
  dp[a[i]] = 1
print(cnt)
# Judge status: Wrong Answer
x = int(input())
for i in range(100000):
  if i * 100 <= x <= i *105:
    print(1)
print(0)
# Judge status: Accepted
N = int(input())
v = [list(map(int,input().split())) for _ in range(N)]

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

for i in range(N):
    for j in range(3):
        for k in range(3):
            if j==k:continue
            dp[i+1][k] = max(dp[i+1][k],dp[i][j]+v[i][k])
            
print(max(dp[N][i] for i in range(3)))
# Judge status: Wrong Answer
s = input()
t = input()
if set(s) == set(t):
  for i in set(s):
    if s.count(i) != t.count(i):
      break
      print('No')
      exit()
  print('Yes')
else:
  print('No')
# Judge status: Accepted
n = int(input())

lucas = [2, 1]
for i in range(2, n+1):
    lucas.append(lucas[i-1] + lucas[i-2])

print(lucas[-1])
# Judge status: Accepted
S = input()
s1 = S[0] + S[1]
s2 = S[2] + S[3]

if "00" < s1 < "13" and "00" < s2 < "13" :
    print("AMBIGUOUS")
elif "00" < s2 < "13" :
    print("YYMM")
elif "00" < s1 < "13" :
    print("MMYY")
else :
    print("NA")
# Judge status: Accepted
Alice, Bob = map(int, input().split())

if Alice == 1:
  Alice = 14
if Bob == 1:
  Bob = 14
  
if Alice > Bob:
  print("Alice")
elif Alice < Bob:
  print("Bob")
else:
  print("Draw")
# Judge status: Accepted
N,a,b = map(int,input().split())
mod = 10**9+7
inv_t = [0]+[1]
for i in range(2,b+1):
  inv_t += [inv_t[mod % i] * (mod - int(mod / i)) % mod]

def cmb(n, r):
    res = 1
    aaa = 1
    for i in range(r):
        res = res *(n-i) * inv_t[i+1]  %mod
    return res % mod

ans = pow(2,N,mod)-1-cmb(N,a)-cmb(N,b)
print(ans%mod)
# Judge status: Accepted
n=int(input())
s=input()
tmp = s.count("R") * s.count("G") * s.count("B")

for i in range(n):
    for j in range(i+1, n):
        if 2*j-i < n:
            if s[i]!=s[j] and s[i]!=s[2*j-i] and s[j]!=s[2*j-i]:
                tmp-=1
print(tmp)
# Judge status: Wrong Answer
x = int(input())
bekis = [1]
for i in range(2,35):
    for j in range(2,15):
        v = i**j
        if v > x: break
        bekis.append(v)

print(bekis[-1])
# Judge status: Accepted
#abc042_b
N, M = map(int,input().split())
S = [input() for i in range(N)]
S.sort()
print("".join(S))
# Judge status: Accepted
# -*- coding: utf-8 -*-
import math


def main():
    n = int(input())
    a = list(map(int, input().split()))

    cnt = 0
    while True:

        is_exist_odd = False
        for _a in a:
            if _a % 2 == 1:
                is_exist_odd = True
                break

        if is_exist_odd:
            break

        a = list(map(lambda _a: _a / 2, a))
        cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()