Harryxun/stf_run huggingface dataset:
N = int(input())
A = map(int, input().split())

ans = 1

import sys

if 0 in A:
  print(0)
  sys.exit()
  

for a in A:
  ans *= a
	if ans > pow(10, 18):
  	print(-1)
  	sys.exit()

print(ans)
  

### FIXED CODE ###

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

ans = 1

import sys

if 0 in A:
  print(0)
  sys.exit()
  
for a in A:
  ans *= a
  if ans > pow(10, 18):
      print(-1)
      sys.exit()

print(ans)
n = int(input())
array = []
for i in range(2,33):
  if j in range(10):
    a = i**j
    if a <= n:
      array.append(a)
array.sort(reversed=True)
print(array[0])
  

### FIXED CODE ###

n = int(input())
array = []
for i in range(1,33):
  for j in range(2,10):
    a = i**j
    if a <= n:
      array.append(a)
array.sort(reverse=True)
print(array[0])
n=int(input())
t,a=map(int,input().split())

h=[int(input()) for i in range(n)]

min=1000
for i in range(n):
  temp=abs(t-0.006*h[i]-a)
  print(temp)
  if min>temp:
    min=temp
    id=i
print(i+1)

### FIXED CODE ###

n=int(input())
t,a=map(int,input().split())

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

min=1000
for i in range(n):
  temp=abs(a-t+0.006*h[i])
  if min>temp:
    min=temp
    id=i
print(id+1)
o = list(input())
e = list(input())
l = []
for x in range(max(len(o), len(e))):
    l.append(o[x])
    l.append(e[x])
print(''.join(l))

### FIXED CODE ###

o = list(input())
e = list(input())
ls = []
for x in range(min(len(o), len(e))):
    ls.append(o[x])
    ls.append(e[x])
else:
    if len(o) < len(e):
        for i in range(x+1, len(e)):
            ls.append(e[i])
    elif len(o) > len(e):
        for i in range(x+1, len(o)):
            ls.append(o[i])
print(''.join(ls))
n, k = map(int,input().split())
al = list(map(int,input().split()))
dics = {}

for i in range(n):
    if al[i] in dics:
        dics[al[i]] = dics[al[i]] + 1
    else:
        dics.update({al[i]:1})
        
counts = len(dics.values())
kesu = 0
sortv = list(sorted(dics.values()))

if len(sortv) > k:
    for i in range(n-k):
        kesu = kesu + sortv[i]
print(kesu)

### FIXED CODE ###

n, k = map(int,input().split())
al = list(map(int,input().split()))
dics = {}
 
for i in range(n):
    if al[i] in dics:
        dics[al[i]] = dics[al[i]] + 1
    else:
        dics.update({al[i]:1})
        
counts = len(dics.values())
kesu = 0
sortv = list(sorted(list((dics.values()))))

i = counts
j = 0
while i > k:
    kesu = kesu + sortv[j]
    i = i - 1
    j = j + 1
print(kesu)
#from functools import lru_cache
import sys
import math
def vfunc(f): return lambda *lst, **kwargs: list(map(lambda *x:f(*x,**kwargs),*lst))

def reader():return vfunc(lambda l:l.split())(sys.stdin.readlines())

ls = rvfunc(int)(reader())
n,k=ls[0]
a=ls[1]

def reqk(l):
    return sum(vfunc(lambda aa:math.ceil(aa/float(l))-1)(a))
def binary_search(imin=None,imax=None):
    if [imin,imax]==[None]*2: imin,imax=0,10**9+1
    if (imax < imin):
        return imin
    else:
        imid = int(imin + (imax - imin) / 2)
        if (reqk(imid)<=k):return binary_search(imin, imid - 1)
        elif (reqk(imid)>k):return binary_search(imid + 1, imax)
print(binary_search() if k!=0 else max(a))


### FIXED CODE ###

#from functools import lru_cache
import sys
import math
def vfunc(f): return lambda *lst, **kwargs: list(map(lambda *x:f(*x,**kwargs),*lst))
def rvfunc(f): return lambda *lst, **kwargs: list(map(lambda *x:rvfunc(f)(*x,**kwargs) if all(vfunc(lambda y:isinstance(y,list))(x)) else f(*x,**kwargs),*lst))

def reader():return vfunc(lambda l:l.split())(sys.stdin.readlines())
sys.setrecursionlimit(100000)
ls = rvfunc(int)(reader())
n,k=ls[0]
a=ls[1]

def reqk(l):
    return sum(vfunc(lambda aa:math.ceil(aa/float(l))-1)(a))
def binary_search(imin=None,imax=None):
    if [imin,imax]==[None]*2: imin,imax=1,10**9+1
    if (imax < imin):
        return imin
    else:
        imid = int(imin + (imax - imin) / 2)
        if (reqk(imid)<=k):return binary_search(imin, imid - 1)
        elif (reqk(imid)>k):return binary_search(imid + 1, imax)
print(binary_search() if k!=0 else max(a))
N=int(input())
lr=[list(map(int,input())) for _ in range(N)]
print(sum([e[1]-e[0]+1 for e in lr]))


### FIXED CODE ###

N=int(input())
lr=[list(map(int,input().split())) for _ in range(N)]
print(sum([e[1]-e[0]+1 for e in lr]))
A, B, C, X, Y = map(int, input().split())

print(mix(X, Y) * 2 * C + (A if X > Y else B) * abs(X-Y), A * X + B * Y, max(X, Y) * 2 * C)

### FIXED CODE ###

A, B, C, X, Y = map(int, input().split())

print(min(min(X, Y) * 2 * C + (A if X > Y else B) * abs(X-Y), A * X + B * Y, max(X, Y) * 2 * C))
import sys

def check(a,b,k):
    if a + b == k:
        b = 0
        a = 0
    elif a < k:
        b = b - (k-a)
        a = 0
    elif a > k:
        a = a - k
    return a,b

a,b,k=map(int,input().split(" "))
if len(str(a)) > 12 or len(str(b)) > 12 or len(str(k)) > 12:
  a=0
  b=0
  print(str(a),str(b))
  sys.exit()

else:
    if a > 0 or k > 0:
        A,B=check(a,b,k)
    elif a <= 0 and b > 0:
        b = k -b
    print(str(A),str(B))

### FIXED CODE ###

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

if k <= a:
    print(str(a-k),str(b))
elif k <= a+b:
    print(str(0),str(b-(k-a)))
else:
    print(str(0),str(0))
N = int(input())
H = list(map(int, input().split()))

result = 0
for i in range(0, N):
    if tempres != 0:
        tempres -= 1
        break
    for j in range(i, N - 1):
        if H[j] >= H[j + 1]:
            tempres += 1
        else:
            break
    result = max(result, tempres)
    if result >= N - i - 1:
        break
print(result)


### FIXED CODE ###

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

result = 0
tempres = 0
for i in range(0, N):
    if tempres != 0:
        tempres -= 1
        continue
    for j in range(i, N - 1):
        if H[j] >= H[j + 1]:
            tempres += 1
        else:
            break
    result = max(result, tempres)
    if result >= N - i - 1:
        break
print(result)
N, K = tuple(map(int, input().split()))

def new_link_n(i, j):
    s = len(link[i] + link[j])
    for i_link in link[i]:
        if i_link in link[j]:
            s -= 1
        else:
            for j_link in link[j]:
                if i_link in link[j_link]:
                    s -= 1
                    break
    for j_link in link[j]:
        if j_link in link[i]:
            s -= 1
        else:
            for i_link in link[i]:
                if j_link in link[i_link]:
                    s -= 1
                    break
    return s

# Kを減らす
def make_link1(M, s):
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            if j in link[i]:
                continue
            n = new_link_n(i, j)
            if n <= 0 and s + n >= K:
                link[i].append(j)
                link[j].append(i)
                s += n
                M += 1
                if s == K:
                    return M
                return make_link1(M, s)

# Kを増やす
def make_link2(M, s):
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            if j in link[i]:
                continue
            n = new_link_n(i, j)
            if n >= 0 and s + n <= K:
                link[i].append(j)
                link[j].append(i)
                s += n
                M += 1
                if s == K:
                    return M
                return make_link2(M, s)

        
if K > (N - 1) * (N - 2) / 2:
    print(-1)
else:
    link = {i: [] for i in range(1, N+1)}
    for i in range(1, N):
        link[i].append(i + 1)
        link[i + 1].append(i)
    M = N - 1
    now_k = N - 2
    if now_k == K:
        pass
    elif now_k > K:
        M = make_link1(M, now_k)
    else:
        M = make_link2(M, now_k)
    print(M)
    for i in range(1, N+1):
        for j in link[i]:
            if i < j:
                print(i, j)

### FIXED CODE ###

N, K = tuple(map(int, input().split()))

def make_link(M, s):
    for i in range(2, N+1):
        for j in range(i+1, N+1):
            link[i].append(j)
            M += 1
            s -= 1
            if s == K:
                return M

max_link = (N - 1) * (N - 2) / 2
if K > max_link:
    print(-1)
else:
    link = {i: [] for i in range(1, N+1)}
    for i in range(2, N+1):
        link[1].append(i)
    M = N - 1
    if max_link == K:
        pass
    else:
        M = make_link(M, max_link)
    print(M)
    for i in range(1, N+1):
        for j in link[i]:
            print(i, j)
def merge(a, left, mid, right):
    global count
    n1 = mid - left
    n2 = right - mid
    L = a[left:left + n1] + SENTINEL
    R = a[mid:mid + n2] + SENTINEL
    i = j = 0
    for k in range(left, right):
        if L[i] <= R[j]:
            a[k] = L[i]
            i += 1
        else:
            a[k] = R[j]
            j += 1
    count += right - left

def merge_sort(a, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        merge_sort(a, left, mid)
        merge_sort(a, mid, right)
        merge(a, left, mid, right)

SENTINEL = 1000000001
n = int(input())
a = list(map(int, input().strip().split()))
count = 0
merge_sort(a, 0, len(a))
print(' '.join(map(str, a)))
print(count)

### FIXED CODE ###

def merge(a, left, mid, right):
    global count
    n1 = mid - left
    n2 = right - mid
    L = a[left:left + n1] + [SENTINEL]
    R = a[mid:mid + n2] + [SENTINEL]
    i = j = 0
    for k in range(left, right):
        if L[i] <= R[j]:
            a[k] = L[i]
            i += 1
        else:
            a[k] = R[j]
            j += 1
    count += right - left

def merge_sort(a, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        merge_sort(a, left, mid)
        merge_sort(a, mid, right)
        merge(a, left, mid, right)

SENTINEL = 1000000001
n = int(input())
a = list(map(int, input().strip().split()))
count = 0
merge_sort(a, 0, len(a))
print(' '.join(map(str, a)))
print(count)
import sys

f = [0, 1] * 500000
i = 3
while i * i <= 2 * xx:
    if f[i] == 1:
        j = i * i
        while j <= 2 * xx:
            f[j] = 0
            j += i + i
    i += 2

f.pop(0)
f.pop(1)
 
for n in sys.stdin:
    i = int(n)
    if i < 2:
        print(0)
    else:
        print(sum(f[:i - 1]))

### FIXED CODE ###

import sys

f = [1, 0, 0, 0, 1, 0] * (1000000 // 6 + 1)
f = [0, 0, 1, 1] + f[3:-2]

i = 5
while i < 1000:
    if f[i] == 1:
        j = i * i
        while j <= 1000000:
            f[j] = 0
            j += i + i
    i += 2

for n in sys.stdin:
    i = int(n)
    print(sum(f[:i + 1]))
l=[]
n,W=input().split()
n=int(n)
W=int(W)
for i in range(n):
	item=list(map(int,input().split))
	l.append([item[1],item[0]])

# n=4
# l=[[2,3],[1,2],[3,4],[2,2]] #w,v
# W=5

def solve(i,w):
	if i==n:
		return(0)
	elif w-l[i][0]<0:
		return(0)
	else:
		a=solve(i+1,w)
		b=l[i][1]+solve(i+1,w-l[i][0])
		if b>a:
			return(b)
		else:
			return(a)

print(solve(0,W))

### FIXED CODE ###

value=[0]
weight=[0]
n,W=input().split()
n=int(n)
W=int(W)
for i in range(n):
	item=list(map(int,input().split()))
	value.append(item[0])
	weight.append(item[1])

dp=[[0 for j in range(W+1)] for i in range(n+1)]
for i in range(n+1):
	for j in range(W+1):
		if i==0:
			res=0
		elif j-weight[i]<0:
			res=dp[i-1][j]
		else:
			res=max(dp[i-1][j-weight[i]]+value[i],dp[i-1][j])
		dp[i][j]=res
print(dp[n][W])
h = int(input())
w = int(input())

r = h*w /2 if h%2 ==0 or w %2==0 else (h*w+1)/2 

print(r)

### FIXED CODE ###

s = input()
s =  s.split()

h = int(s[0])
w = int(s[1])
if w == 1 or h == 1:
    print(1)
else: 
	r = (h*w+1) /2 if h %2 !=0 and w %2 !=0 else h*w/2
	print(int(r))
S = input()
if S == "Sunny":
  print("Cloudy")
else if S == "Cloudy":
  print("Rainy")
else:
  print("Sunny")

### FIXED CODE ###

S = input()
if S == 'Sunny':
  print('Cloudy')
elif S == 'Cloudy':
  print('Rainy')
else:
  print('Sunny')
# -*- coding: utf-8 -*-
#a,b,c,d,e,k = 2,4,7,8,15,1
#box = [a,b,c,d,e]
box = []
for i in range(0,5):
    box.append(int(input())
c = 0
for i in range(0,4):
    if box[i+1] - box[i] > k :
        c +=1
    else:
        pass
if c == 0:
    print("Yay!")
else:
    print(":(")

### FIXED CODE ###

# -*- coding: utf-8 -*-
#a,b,c,d,e,k = 2,4,7,8,15,1
#box = [a,b,c,d,e]
import itertools
box = []
for i in range(0,5):
    box.append(int(input()))
k = int(input())
c = 0
for two in list(itertools.combinations(box,2)):
    if (two[1]- two[0] > k):
        c +=1
    else:
        pass
if c == 0:
    print("Yay!")
else:
    print(":(")
n = int(input())
s = list(input())
k = int(input())

for i in range(n):
    if s[i] != s[k] :
        s[i] = "*"

for i in s:
    print(i,end="")

### FIXED CODE ###

n = int(input())
s = list(input())
k = int(input())


for i in range(n):
    if s[i] != s[k-1] :
        s[i] = "*"

for i in s:
    print(i,end="")
al = [ord(i) for i in range(ord("a"), ord("a")+26)]

str = input()

print(al[al.index(str)+1])

### FIXED CODE ###

al = [chr(i) for i in range(ord("a"), ord("a")+26)]

str = input()

print(al[al.index(str)+1])
S = input()
N = len(S)
if S == S[::-1] and S[:(N - 1)//2][::-1] == S[:(N - 1)//2] and S[(N + 3)//2][::-1] == S[(N + 3)//2]:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

from itertools import combinations
n, m = map(int, input().split())
r = []
i = 0
j = -1
c = 0
for _ in range(n):
    i += 2
    r.append(i)
for _ in range(m):
    j += 2
    r.append(j)
r.sort()
for k in list(combinations(r, 2)):
    if sum(k) % 2 == 0:
        c += 1

print(c)
X=int(input())
Y=int(input())
Z=int(input())
X, Y, Z = Z, X, Y
print(X,Y,Z)

### FIXED CODE ###

A,B,C=map(int,input().split())
print(C,A,B)
from collections import deque,defaultdict
N,X,D = map(int,input().split())
d = defaultdict(list)
if D<0:
    D *= -1
    X *= -1

for m in range(N+1):
    if m==0:
        a = 0
        b = 0
    else:
        a = X*m+(m*(m-1)*D)//2
        b = X*m+(m*(2*N-m-1)*D)//2
    d[a%D].append([a,b])


ans = 0
for k in d:
    q = d[k]
    q.sort()
    q = deque(q)
    while q:
        a1,b1 = q.popleft()
        if q:
            a2,b2 = q.popleft()
            if a2 <= b1:
                q.appendleft([a1,b2])
            else:
                ans += (b1-a1)//D+1
                l.append([a1,b1])
                q.appendleft([a2,b2])
        else:
            ans += (b1-a1)//D+1


print(ans)

### FIXED CODE ###

from collections import defaultdict
N,X,D = map(int,input().split())
d = defaultdict(list)
if D<0:
    D *= -1
    X *= -1

if D != 0:
    for m in range(N+1):
        a = X*m+(m*(m-1)*D)//2
        b = X*m+(m*(2*N-m-1)*D)//2
        d[a%D].append([a,b])


    ans = 0
    for k in d:
        q = d[k]
        q.sort()
        l,r = q[0]
        for i in range(len(q)):
            a,b = q[i]
            if a<=r:
                r = max(r,b)
            else:
                ans += (r-l)//D+1
                l = a
                r = b
        ans += (r-l)//D+1

if D == 0:
    ans = N+1
    if X == 0:
        ans = 1
print(ans)
import numpy as np
a,b= map(int,input().split())
lcm = np.lcm(a, b)
print(lcm)

### FIXED CODE ###


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

def lcm(a, b):
    return a * b // gcd (a, b)
a,b = map(int,input().split())
print(lcm(a,b))
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]


n, m = map(int, input().split())

uf = UnionFind(n+1)

for i in range(m):
    a, b = map(int, input().split())
    uf.union(a, b)

ans = 1
for i in range(1, n+1):
    ans = max(ans, uf.size(i))

print(ans)


### FIXED CODE ###

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]


n, m = map(int, input().split())

uf = UnionFind(n+1)

for i in range(m):
    a, b = map(int, input().split())
    uf.union(a, b)

ans = 1
for i in range(1, n+1):
    ans = max(ans, uf.size(i))

print(ans)
import collections 
n=int(input())
s_list=list(input() for _ in range(n))
c=collections.Ceounter(s_list)
print(len(c.keys()))

### FIXED CODE ###

import collections 
n=int(input())
s_list=list(input() for _ in range(n))
c=collections.Counter(s_list)
print(len(c.keys()))
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,k=map(int,input().split())
    r,s,p=map(int,input().split())
    T=input()
    T_lis=[False]*n
    ans=0
    for i,t in enumerate(T):
        if i-k>=0:
            if T[i-k]==t and T_lis[i-k]:
                continue
        if t=='r':
            ans+=p
        elif t=='s':
            ans+=r
        else:
            ans+=s
        T_lis[i]=True
    print(ans)


if __name__=='__main__':
    main()

### FIXED CODE ###

s,t=input().split()
print(t+s)
import numpy as np

N, K = map(int, input().split())
A = [int(a) for a in input().split()]

K_str = format(K, 'b')
max_order = len(K_str)

B = np.array([list(format(a, '0{}b'.format(max_order)))for a in A]).astype('i')[:, :max_order]
B = B.sum(axis=0)
B = np.where(B < N/2, 1, 0)

X_str = ''.join(map(str, B))

for i in range(max_order):
    if K_str[i] < X_str[i]:
        X_str[i] = 0

X = int(X_str, 2)

print(sum(map(lambda a: X ^ a, A)))

### FIXED CODE ###

import numpy as np

N, K = [int(a) for a in input().split()]
A = [int(a) for a in input().split()]

K = format(K, 'b')
B = [format(a, 'b') for a in A]
max_order = len(max(B + [K], key=len))

K = K.zfill(max_order)
B = np.array([list(b.zfill(max_order)) for b in B], dtype='i')
B = B.sum(axis=0)
B = np.where(B < N/2, '1', '0')

for i, k, b in zip(range(max_order), K, B):
    if k < b:
        B[i] = '0'
    elif k > b:
        break

X = int(''.join(map(str, B)), 2)

print(sum(map(lambda a: X ^ a, A)))
while True:
    a, b = map(int, input().rstrip().split())
    print(len(str(a + b)))



### FIXED CODE ###

while True:
    try:
        a, b = map(int, input().rstrip().split())
        print(len(str(a + b)))
    except Exception:
        break
W, H, x, y, r = [int(i) for i in input().split]


if x,y < 0:
    print("No")
else:
    print("Yes")

### FIXED CODE ###

W, H, x, y, r = [int(i) for i in input().split()]


if x + r <= W and y - r >= 0 and x - r >= 0 and y + r <= H:
    print("Yes")
else:
    print("No")
N,M=map(int,input().split())
L=[int(input()) for _ in range(M)]
ans=0
def dfs(i):
	global ans
	if i==N:
		ans+=1
		# print(i)
		return True
	if i>N:return False
	if i in L:return False
	dfs(i+1)
	dfs(i+2)

dfs(0)
print(ans%1000000007) 

### FIXED CODE ###

N,M=map(int,input().split())
A=set([int(input()) for _ in range(M)])
dp=[0]*(N+1)
dp[0]=1
for i in range(1,N+1):
	dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
	if i in A:
		dp[i]=0
print(dp[N])
n,x=map(int,input().split())
l=list(map(int,input().split()))
d=0
a=1
for i in range(n-1):
    a+=1
    d+=l[i]
    #print(d)
    if d>x:
        break


print(a)

### FIXED CODE ###

x,a=map(int,input().split())
if x>=a:
    print('10')
else:
    print('0')
n,k = map(int,input().split())
an = list(map(int, input().split()))
copyan = an[:]
i = copyan[0]
copyan[0]=10**6
movecount = 1
roopstart = 0
if i != 1:
    while True:
        memo = i
        i = copyan[i-1]
        
        
        if i >=30000:
            yokei = i%(10**6)
            
            break
        copyan[memo-1]=10**6 + movecount
        movecount += 1
        roopstart = i-1
else:
    print(1)
roopnum = movecount - yokei
x = (k-yokei)%roopnum #移動する回数

ans = copyan.index(10**6+yokei+x) +1
print(ans)






### FIXED CODE ###

n,k = map(int,input().split())
an = list(map(int, input().split()))
copyan = an[:]
i = copyan[0]
copyan[0]=10**6
movecount = 1

if i != 1:
    while True:
        memo = i
        if k == movecount:
            print(i)
            
            exit()
        i = copyan[i-1]
        
        if i >=300000:
            yokei = i%(10**6)         
            break
        copyan[memo-1]=10**6 + movecount
        movecount += 1
        
else:
    print(1)
    exit()
roopnum = movecount - yokei
x = (k-yokei)%roopnum

ans = copyan.index(10**6+yokei+x) +1
print(ans)
N,M=map(int,input().split())
arr=[int(x) for x in input().split()]
s=[list(map(int,input().split())) for y in range(M)]
s(key=lambda z: z[1], reverse=True)

sum_a=0
for a,b in s:
    arr+=[b]*a
    sum_a+=a
    if sum_a>=N:
        break

lst=sorted(arr)
ans=sum(lst[-N:])
print(ans)

### FIXED CODE ###

N,M=map(int,input().split())
arr=[int(x) for x in input().split()]
s=[list(map(int,input().split())) for y in range(M)]
s.sort(key=lambda z: z[1], reverse=True)

sum_a=0
for a,b in s:
    arr+=[b]*a
    sum_a+=a
    if sum_a>=N:
        break

lst=sorted(arr)
ans=sum(lst[-N:])
print(ans)
import sys
 
if __name__ == ‘__main__’:
    args = sys.argv
    prices = map(int, args[1:])
    min = prices[0]

    max_profit = 0
    for price in prices:
        if min > price:
            min = price
        max_profit = price - min

    return max_profit


### FIXED CODE ###

n = input()
prices = list()
for idx in range(int(n)):
    tmp = input()
    prices.append(int(tmp))

minp = prices[0]
maxv = prices[1] - prices[0]

for price in prices[1:]:
    maxv = max(maxv, price - minp)
    minp = min(minp, price)

print(maxv)
while(True):
	H,W=list(map(int,input().split()))
	if H==0 and W==0:
		break
	l1=""
	for i in range(W):
		if i%2==0:
			l1+="#"
		else:
			l1+="."
	l1+="\n"
	l2=""
	for i in range(W):
		if i%2==0:
			l2+="."
		else:
			l2+="#"
	l2+="\n"

	l=""
	for i in range(N):
		if i%2==0:
			l+=l1
		else:
			l+=l2

	print(l)

### FIXED CODE ###

while(True):
	H,W=list(map(int,input().split()))
	if H==0 and W==0:
		break
	l1=""
	for i in range(W):
		if i%2==0:
			l1+="#"
		else:
			l1+="."
	l1+="\n"
	l2=""
	for i in range(W):
		if i%2==0:
			l2+="."
		else:
			l2+="#"
	l2+="\n"

	l=""
	for i in range(H):
		if i%2==0:
			l+=l1
		else:
			l+=l2

	print(l)
n = int(input())
line = list(map(int, input().split()))
ans = [0 for i in range(n)]
for i in range(n):
  ans[line[i-1]] = i+1
print(' '.join(ans))


### FIXED CODE ###

n = int(input())
line = list(map(int, input().split()))
ans = ['0' for i in range(n)]
for i in range(n):
  ans[line[i]-1] = str(i+1)
print(' '.join(ans))
a,b = map(int,raw_input().split())
print a*b.2*(a+b)

### FIXED CODE ###

a,b = map(int,raw_input().split())
print a*b,2*(a+b)
from sys import stdin
from math import factorial

if __name__ == '__main__':

    N, K = [int(x) for x in stdin.readline().rstrip().split()]

    tmp = 100000007
    ret = 0
    for r in range(K):
        r += 1
        n = N - K + 1

        ret = factorial(n) // factorial(r) // factorial(n - r)
        ret2 = factorial(K-1) // factorial(r-1) // factorial((K - 1) - (r - 1))

        print(ret * ret2)

### FIXED CODE ###

from sys import stdin
from math import factorial

if __name__ == '__main__':

    N, K = [int(x) for x in stdin.readline().rstrip().split()]

    tmp = 1000000007
    r = 0
    for r in range(K):
        r += 1
        n = N - K + 1

        if n - r < 0 or K - r < 0:
            print(0)
            continue

        ret = factorial(n) // factorial(r) // factorial(n - r)
        ret2 = factorial(K-1) // factorial(r-1) // factorial((K - 1) - (r - 1))

        print((ret * ret2) % tmp)
from sys import stdin
import math

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

lcm_a = int(A[0] * A[1] / math.gcd(A[0], A[1]))

for k in A[2:]:
    lcm_a = int(lcm_a * k / math.gcd(lcm_a, k))

modulo_sum = 0

for k in A:
    modulo_sum += (lcm_a - 1) % k

print(modulo_sum)


### FIXED CODE ###

from sys import stdin

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

lcm_a = A[0] * A[1]

if len(A) > 2:
    for k in A[2:]:
        lcm_a = lcm_a * k

modulo_sum = 0

for k in A:
    modulo_sum += (lcm_a - 1) % k

print(modulo_sum)