Harryxun/stf_run huggingface dataset:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from functools import reduce
mod = 10**9+7


def nCk(n, k):
    # c = reduce(lambda x, y: x*y % mod, range(n, n-k, -1))
    # m = reduce(lambda x, y: x*y % mod, range(1, k+1))
    c = reduce(lambda x, y: x*y % mod, range(n, n-k+1, -1))
    m = reduce(lambda x, y: x*y % mod, range(1, k))
    return c*pow(m, mod-2, mod) % mod


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

ans = pow(2, n, mod) - nCk(n, a) - nCk(n, b) - 1
ans %= mod
print(ans)


### FIXED CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from functools import reduce
mod = 10**9+7

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


def nCk(n, k):
    numer = reduce(lambda x, y: (x * y) % mod, range(n, n - k, -1))
    denom = reduce(lambda x, y: (x * y) % mod, range(1, k + 1))
    return numer * pow(denom, mod - 2, mod) % mod


ans = pow(2, n, mod) - nCk(n, a) - nCk(n, b) - 1
ans %= mod
print(ans)
import sys
import math
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict

MOD = 10**9+7
N = int(input())
dic = defaultdict(int)
gp = []
zero = 0
left_zero = 0
right_zero = 0
for i in range(N):
    a,b = map(int, input().split())
    g = math.gcd(a, b)
    a //= g
    b //= g
    if b < 0:
        a = -a
        b = -b
    if a == 0 and b != 0:
        left_zero += 1
    elif a != 0 and b == 0:
        right_zero += 1
    elif a == 0 and b == 0:
        zero += 1
    else:
        dic[a/b] += 1
        gp.append((a, b))
done = defaultdict(bool)
ans = 1
for a,b in gp:
    k = a/b
    if done[k]: continue
    rk = -b/a
    done[k] = True
    done[rk] = True
    cnt1 = pow(2, dic[k], MOD)-1
    cnt2 = pow(2, dic[rk], MOD)-1
    c = cnt1+cnt2+1
    ans *= c
    ans %= MOD
c1 = pow(2, left_zero, MOD)-1
c2 = pow(2, right_zero, MOD)-1
c = c1+c2+1
ans *= c
ans %= MOD
print(ans-1)


### FIXED CODE ###

import sys
import math
from fractions import Fraction
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict

MOD = 10**9+7
N = int(input())
dic = defaultdict(int)
gp = []
zero = 0
left_zero = 0
right_zero = 0
for i in range(N):
    a,b = map(int, input().split())
    if b < 0:
        a = -a
        b = -b
    if a == 0 and b != 0:
        left_zero += 1
    elif a != 0 and b == 0:
        right_zero += 1
    elif a == 0 and b == 0:
        zero += 1
    else:
        g = math.gcd(a, b)
        a //= g
        b //= g
        dic[str(Fraction(a, b))] += 1
        gp.append((a, b))
done = defaultdict(bool)
ans = 1
for a,b in gp:
    k = str(Fraction(a, b))
    if done[k]: continue
    rk = str(Fraction(-b, a))
    done[k] = True
    done[rk] = True
    cnt1 = pow(2, dic[k], MOD)-1
    cnt2 = pow(2, dic[rk], MOD)-1
    c = cnt1+cnt2+1
    ans *= c
    ans %= MOD
c1 = pow(2, left_zero, MOD)-1
c2 = pow(2, right_zero, MOD)-1
c = c1+c2+1
ans *= c
ans += zero
ans %= MOD
print((ans-1)%MOD)
# AtCoder Beginner Contest 121
# https://atcoder.jp/contests/abc121
import sys
import numpy as np

s2nn = lambda s: map(int, s.split(' '))
ss2nn = lambda ss: map(int, ss)
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    H, W = i2nn()
    h, w = i2nn()
    n = (H - h) * (W - w)
    print(n)

main()


### FIXED CODE ###

# AtCoder Beginner Contest 121
# https://atcoder.jp/contests/abc121
import sys
import numpy as np

s2nn = lambda s: map(int, s.split(' '))
ss2nn = lambda ss: map(int, ss)
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    H, W = i2nn()
    h, w = i2nn()
    n = (H - h) * (W - w)
    print(n)

main()
def warshall_floyd(d, n):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d


H, W = map(int, input().split())

fld = [""] * H
for i in range(H):
    fld[i] = input()

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

d = [[float("inf") for i in range(H * W)] for i in range(H * W)]
for i in range(H):
    for j in range(W):
        if fld[i][j] == '#':
            continue
        for k in range(4):
            x = i + dx[k]
            y = j + dy[k]
            if x < 0 or x >= H or y < 0 or y >= W:
                continue
            if fld[x][y] == ".":
                d[i*H+j][x*H+y] = 1


for i in range(H*W):
    d[i][i] = 0

warshall = warshall_floyd(d, H*W)
ans = 0
for val in warshall:
    for v in val:
        if v != float("inf"):
            ans = max(ans, v)

print(ans)


### FIXED CODE ###

def warshall_floyd(d, n):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d


H, W = map(int, input().split())

fld = [""] * H
for i in range(H):
    fld[i] = input()

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

d = [[float("inf") for i in range(H * W)] for i in range(H * W)]
for i in range(H):
    for j in range(W):
        if fld[i][j] == '#':
            continue
        for k in range(4):
            x = i + dx[k]
            y = j + dy[k]
            if x < 0 or x >= H or y < 0 or y >= W:
                continue
            if fld[x][y] == ".":
                d[i*W+j][x*W+y] = 1


for i in range(H*W):
    d[i][i] = 0

warshall = warshall_floyd(d, H*W)
ans = 0
for val in warshall:
    for v in val:
        if v != float("inf"):
            ans = max(ans, v)

print(ans)
i = int(input())
 
if i = a :
    print("vowel")
elif i = i:
    print("vowel")
elif i = u:
        print("vowel")
elif i = e:
        print("vowel")
elif i = o:
    print("vowel")
else:
    print("consonant")

### FIXED CODE ###

a = ['a','i','u','e','o']
n = str(input())
 
if n in a:
    print('vowel')
else:
    print('consonant')
a,b,c=map(int,input().split())
print(a if b=c else b if a=c else c)

### FIXED CODE ###

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

a = int(a)
b = b.replace(".","")
b= int(b)
print(int(a*b/100)

### FIXED CODE ###

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

a = int(a)
b = b.replace(".", "")
b = int(b)
print(int(a*b)//100)
n = int(input())
al = list(map(int, input().split()))

if al[1] > al[0]:
    now = 'U'
elif al[1] < al[0]:
    now = 'D'
else:
    now = 'E'

cnt = 1
for i in range(2, n):
    if now == 'U':
        if al[i] > al[i-1] or al[i] == 'E':
            now = 'U'
        elif al[i] < al[i-1]:
            cnt += 1
            i += 1
            now = 'E'
    elif now == 'D':
        if al[i] < al[i-1] or al[i] == 'E':
            now = 'D'
        elif al[i] > al[i-1]:
            cnt += 1
            now = 'E'
    elif now == 'E':
        if al[i] == al[i - 1]:
            now = 'E'
        elif al[i] > al[i - 1]:
            now = 'U'
        elif al[i] < al[i - 1]:
            now = 'D'
print(cnt)


### FIXED CODE ###

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

if n == 1:
    print(1)
    exit()
    
if al[1] > al[0]:
    now = 'U'
elif al[1] < al[0]:
    now = 'D'
else:
    now = 'E'

cnt = 1
for i in range(2, n):
    if now == 'U':
        if al[i] > al[i-1] or al[i] == 'E':
            now = 'U'
        elif al[i] < al[i-1]:
            cnt += 1
            i += 1
            now = 'E'
    elif now == 'D':
        if al[i] < al[i-1] or al[i] == 'E':
            now = 'D'
        elif al[i] > al[i-1]:
            cnt += 1
            now = 'E'
    elif now == 'E':
        if al[i] == al[i - 1]:
            now = 'E'
        elif al[i] > al[i - 1]:
            now = 'U'
        elif al[i] < al[i - 1]:
            now = 'D'
print(cnt)
import itertools

N, K = map(int, input().split())
menu = {}

t0 = time.time()
for i in range(N):
    t, d = map(int, input().split())
    menu[i] = (t, d)

def manzoku(s):
    return sum([menu[i][1] for i in s]) + len(set([menu[i][0] for i in s]))**2

shushi = itertools.combinations(menu, K)
print(max([manzoku(c) for c in shushi]))


### FIXED CODE ###

N, K = map(int, input().split())
menu_ = []

for i in range(N):
    t, d = map(int, input().split())
    menu_.append((t, d))

menu = sorted(menu_, key = lambda x:x[1], reverse=True)
neta = set()
duplicates = []

for m in menu[:K]:
    if m[0] in neta:
        duplicates.append(m[1])
    else:
        neta.add(m[0])

p = sum([d for (t, d) in menu[:K]]) + len(neta)**2
ans = p

for m in menu[K:]:
    if m[0] not in neta and duplicates:
        neta.add(m[0])
        duplicate = duplicates.pop()
        
        p += (m[1] - duplicate) + 2 * len(neta) - 1 
        #print(ans, p)
        ans = max(ans, p)

print(ans)
import bisect
import collections
import copy
import functools
import heapq
import math
import sys
from collections import deque
from collections import defaultdict
from fractions import Fraction
input = sys.stdin.readline
sys.setrecursionlimit(10**9)
INF = float("inf")
MOD = 10**9+7

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

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

for i in range(N):
    d[A[i]] += 1

T = [0]
W = []
for k in d.keys():
    if d[k] >= 2:
        T.append(k)
        T.append(24-k)
    else:
        W.append(k)
#print(T,W)

ans = []

w = len(W)
K = 2 # 選択肢の数
for i in range(K**w):
    TF=[0]*w

    for j in range(w):
        TF[w-j-1] = i % K
        i //= K
    
    l = copy.deepcopy(T)
    for j in range(w):
        if TF[j] == 1:
            l.append(24-W[j])
        else:
            l.append(W[j])
    
    l.sort()
    m = 24
    for j in range(1,N+1):
        m = min(m,l[j] - l[j-1])
    ans.append(m)

print(max(ans))

### FIXED CODE ###

import bisect
import collections
import copy
import functools
import heapq
import math
import sys
from collections import deque
from collections import defaultdict
from fractions import Fraction
input = sys.stdin.readline
sys.setrecursionlimit(10**9)
INF = float("inf")
MOD = 10**9+7

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

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

for i in range(N):
    d[A[i]] += 1

T = [0]
W = []
for k in d.keys():
    if d[k] > 2:
        print(0)
        exit()
    if d[k] == 2:
        T.append(k)
        T.append(24-k)
    else:
        W.append(k)
#print(T,W)

ans = []

w = len(W)
K = 2 # 選択肢の数
for i in range(K**w):
    TF=[0]*w

    for j in range(w):
        TF[w-j-1] = i % K
        i //= K
    
    l = copy.deepcopy(T)
    for j in range(w):
        if TF[j] == 1:
            l.append(24-W[j])
        else:
            l.append(W[j])
            
    l.sort()
    l.append(24)
    #print(l)
    m = 24
    for j in range(1,len(l)):
        m = min(m,l[j] - l[j-1])
    ans.append(m)

print(max(ans))
n = input()
l = len(n)
count = 0

for i in range(1, l, 2):
  count += 9 * 10 ** (i-1)

if l % 2 == 1:
  count += int(n[1:]) + 1

print(count)

### FIXED CODE ###

n = int(input())
count = 0

for i in range(1, n+1):
  if len(str(i)) % 2 == 1:
    count += 1
    
print(count)
nums = input().sprit()
(W, H, x, y, r) = [int(i) for i in input().split()]
if r <= x <= W - r and r <= y <= H - r:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

nums = input().split()
a = int(nums[0])
b = int(nums[1])
c = int(nums[2])
 
if a > b:
    tmp = a
    a = b
    b = tmp
if b > c:
    tmp = b
    b = c
    c = tmp
if a > b:
    tmp = a
    a = b
    b = tmp
 
print(a, b, c)
N=int(input())
if N%2=1:
  a=(N+1)/2
  print(a)
else:
  b=N/2
  print(b)

### FIXED CODE ###

N=int(input())
if N%2==0:
  a=N/2
  b=a/N
  print(b)
else:
  t=N+1
  c=t/2
  d=c/N
  print(d)
n,d= map(int, input().split())
x,y=[int(input()) for i in range(n)]

def distance_count():
  s=0
  for i in range(N)
  　　if (x[i]**2 + y[i]**2)**(1/2)<= d:
     　　s=s+1
  return s

print(distance_count(x,y))

### FIXED CODE ###

N,D = map(int, input().split())
XY = [map(int, input().split()) for _ in range(N)]
X,Y = [list(i) for i in zip(*XY)]

s=0
for i in range (N):
  if X[i]*X[i]+Y[i]*Y[i]<=D*D:
    s=s+1
print(s)
N = int(input())
A_list = [int(item) for item in input().split()]

mini = 2020202020 * 200000
for j in range(1,N):
    F, B = A_list[:j], A_list[j:]
    delta = abs(sum(F) - sum(B))
    if delta <= mini:
        mini = delta

print(mini)

### FIXED CODE ###

x, y = [int(item) for item in input().split()]

res = 0

if x == 1:
    res += 300000
elif x == 2:
    res += 200000
elif x == 3:
    res += 100000

if y == 1:
    res += 300000
elif y == 2:
    res += 200000
elif y == 3:
    res += 100000

if x == 1 and y == 1:
    res += 400000

print(res)
N, M = map(int, input().split())
a = []
for i in range(N):
    listed_a = list(map(int, input().split())).pop(0)
    a.append(set(listed_a))


seki = a[0]
for i in range(N-1):
    seki = seki & a[i+1]
    
print(len(seki))


### FIXED CODE ###

N, M = map(int, input().split())
a = []
for i in range(N):
    listed_a = list(map(int, input().split()))
    listed_a.pop(0)
    a.append(set(listed_a))


seki = a[0]
for i in range(N-1):
    seki = seki & a[i+1]
    
print(len(seki))
n,m=map(int,input().split())
a=[0]*m
b=[list(map(int,input().split())) for _ in range(n) ]
      
for i in range(n):
  c=b[i][0]
  for j in range(c):
    a[b[i][j]]+=1
ans=0
for i in range(m):
  if a[i]==n:
    ans+=1
print(ans)

### FIXED CODE ###

n,m=map(int,input().split())
a=[0]*m
b=[list(map(int,input().split())) for _ in range(n) ]
      
for i in range(n):
  c=b[i][0]
  for j in range(1,c+1):
    a[b[i][j]-1]+=1

print(a.count(n))
N, C = tuple(map(int, input().split()))
    events = []
    tmax = 0
    for i in range(N):
        s, t, c = map(int, input().split())
        start = (s-0.5, 1)
        end = (t, 0)
        events.append(start)
        events.append(end)
        if tmax < t:
            tmax = t
    events.sort()
    idx = 0
    cnt = 0
    res = 0
    events.append((0,-1))
    for t in range(tmax + 1):
        while events[idx][0] <= t:
            event = events[idx]
            if event[1] == 1:
                cnt += 1
                if res < cnt:
                    res = cnt
            elif event[1] == 0:
                cnt -= 1
            else:
                break
            idx += 1
    print(res)

### FIXED CODE ###

from collections import defaultdict as dd
N, C = tuple(map(int, input().split()))
events = []
tmax = 0
dic=dd(list)
for i in range(N):
    s, t, c = map(int, input().split())
    dic[c].append((s,t))
eps = 0.5
for k,v in dic.items():
    v1 = sorted(v)
    lev = len(v1)
    prev = [-1,-1]
    for i,val in enumerate(v1):
        if tmax < val[1]:
            tmax = val[1]
        if prev == [-1,-1]:
            prev[0] = val[0]
            prev[1] = val[1] # end_time
            if lev != 1:
                continue
            else:
                events.append((prev[0]-eps, 1))
                events.append((prev[1], 0))
                break
        if prev[1] == val[0]:# prev_end == now_start
            prev[1] = val[1]
            if i == lev - 1:
                events.append((prev[0] - eps, 1))
                events.append((prev[1], 0))
                break
        else:
            events.append((prev[0]-eps, 1))
            events.append((prev[1], 0))
            prev[0] = val[0]
            prev[1] = val[1]
            if i==lev-1:
                events.append((val[0]-eps, 1))
                events.append((val[1], 0))
                break
events.sort()
idx = 0
cnt = 0
res = 0
events.append((0,-1))
for t in range(tmax + 1):
    while events[idx][0] <= t:
        event = events[idx]
        if event[1] == 1:
            cnt += 1
            if res < cnt:
                res = cnt
        elif event[1] == 0:
            cnt -= 1
        else:
            break
        idx += 1
print(res)
n = int(input())
al = list(map(int,input().split()))

ifsums = 0
for i in range(1,n):
    ifsums = ifsums + abs(a[i] - a[i-1])
nal = []
nal.append(abs(a[1] - a[0]))
nal.append(abs(a[n-1] - a[n-2]))

for i in range(1,n-1):
    nal.append(abs(a[i] - a[i-1]) + abs(a[i+1] - a[i]) - a[i])
    
print(ifsums - max(nal))




### FIXED CODE ###

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



an = [0]
for i in range(n):
    an.append(a[i])       
an.append(0)

ifsums = 0
nal = []

for i in range(0,n+1):
    ifsums = ifsums + abs(an[i + 1]   - an[i])

for i in range(1,n+1):
    nal.append(ifsums - ( abs(an[i] - an[i-1]) + abs(an[i+1] - an[i]) - abs(an[i+1] -  an[i-1])  ))


for i in range(len(nal)):
    print(nal[i])
N, M = map(int, input().split())

graph = [ [] for _ in range(N) ]

for i in range(M):
    x, y = map(int, input().split())
    graph[x-1].append(y-1)

dp = [-1] * N

def cnt(j):
    if dp[j] != -1:
        return(dp[j])
    else:
        dp[j] = 0
        for k in graph[j]:
            dp[j] = max(cnt(k)+1, dp[j])
        return dp[j]

print(max([ cnt(i) for i in range(N) ]))


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**5)

N, M = map(int, input().split())

graph = [ [] for _ in range(N) ]

for i in range(M):
    x, y = map(int, input().split())
    graph[x-1].append(y-1)

dp = [-1] * N
length = [0] * N

def cnt(j):
    if dp[j] != -1:
        return(dp[j])
    else:
        dp[j] = 0
        for k in graph[j]:
            dp[j] = max(cnt(k)+1, dp[j])
        return dp[j]

for i in range(N):
    length[i] = cnt(i)

print(max(length))
q=[]
vis=set() 
q=[i for i in range(1,10)]
nums=[]
while q:
   # nums.append(t)
    t=q.pop(0)
    nums.append(t)
    if not t*10+9 in vis  and t*10+9<=10**16:
        q.append(t*10+9)
        vis.add(t*10+9)
nums.sort()
k=int(input())
for i in range(k):
    print(nums[i])

### FIXED CODE ###

def s(n):
    ret = 0
    while n > 0:
        ret += n % 10
        n //= 10
    return ret
numbers = [999999999999999999]
while numbers[-1] > 1:
    for d in range(0, 100):
        n = numbers[-1]
        m = n - 10 ** d
        if n * s(m) >= m * s(n):
            numbers.append(m)
            break
numbers = list(reversed(numbers))

n = int(input())
for i in range(n):
    print(numbers[i])
l,r = map(int, input().split())
gap = r-l

vlist = []
mini = 2019
xlist = []

for x in range(gap+1):
    v = (l+x) % 2019
    vlist.append(v)

mini = min(vlist)
for x in vlist:
    if v <= mini+1:
        xlist.append(x)
        

xlist.sort()
#print(vlist)

#res = i*j % 2019
print((xlist[0]*xlist[1])%2019)

### FIXED CODE ###

l,r = map(int, input().split())
gap = r-l
 
vlist = []
mini = 2019
 
for x in range(gap+1):
    v = (l+x) % 2019
    vlist.append(v)
    if v == 0:
        print(0)
        exit()
 
vlist.sort()

mini = 2019

for i in vlist:
    for j in vlist:
        if i==j:
            pass
        else:
            temp = (i*j) %2019
            mini = min(temp, mini)
            if mini == 0:
                print(0)
                exit()

print(mini)
    
#print((vlist[0]*vlist[1])%2019)
#print((vlist[0]*vlist[1])%2019)
n,m=map(int,input().split())

a_lis=[list(map(int,input().split())) for i in range(n)]
c_lis=[list(map(int,input().split())) for i in range(m)]

for i in range(n):
  num=0
  ans=10**8
  for j in reversed(range(m)):
    a=a_lis[i]
    c=c_lis[j]
    num=abs(a[0]-c[0])+abs(a[1]-c[1])
    ans=min(ans,num)
    if num==ans:
      cnt=j+1
  print(cnt)
    


### FIXED CODE ###

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

a_lis=[list(map(int,input().split())) for i in range(n)]
c_lis=[list(map(int,input().split())) for i in range(m)]

for i in range(n):
  num=0
  ans=10**10
  for j in reversed(range(m)):
    a=a_lis[i]
    c=c_lis[j]
    num=abs(a[0]-c[0])+abs(a[1]-c[1])
    ans=min(ans,num)
    if num==ans:
      cnt=j+1
  print(cnt)
def main():
    _ = int(input())
    A = list(int(c) for c in input().split(' '))

    
    tmp = []
    for i in range(len(A)-1):
        if A[i] != A[i+1]:
            tmp.append(A[i])
    if A[-1] != tmp[-1]:
        tmp.append(A[-1])
    A = tmp
    #print(A)

    money = 1000
    if len(A) < 2:
        return 1000

    if len(A) == 2:
        if A[0] < A[1]:
            kabu = money // A[0]
            money -= kabu*A[0]
            money += kabu*A[1]
            return money
        else:
            return 1000

    l = []
    kabu = 0
    if A[1] > A[0]:
        ascending = True
        kabu = money // A[0]
        money -= kabu*A[0]
    else:
        ascending = False
    for i in range(len(A)-1):
        #print(A[i],kabu,money)
        if ascending:  #上昇中
            if A[i] > A[i+1]:
                #下降に転じたので売り
                if kabu > 0:
                    money += kabu*A[i]
                    kabu = 0
                    ascending = False
                else:
                    pass
            else:
                continue
        else:  #下降中
            if A[i] < A[i+1]:
                #上昇したので買い
                assert kabu == 0
                kabu = money // A[i]
                money -= kabu*A[i]
                ascending = True
            else:
                continue
    if kabu > 0:
        money += kabu*A[-1]
        kabu = 0
    return money
if __name__ == "__main__":
    ret = main()
    print(ret)

### FIXED CODE ###


def main():
    _ = int(input())
    A = list(int(c) for c in input().split(' '))

    tmp = []
    for i in range(len(A)-1):
        if A[i] != A[i+1]:
            tmp.append(A[i])
    if len(tmp) == 0:
        return 1000
    if A[-1] != tmp[-1]:
        tmp.append(A[-1])
    A = tmp
    #print(A)

    money = 1000
    if len(A) < 2:
        return 1000

    if len(A) == 2:
        if A[0] < A[1]:
            kabu = money // A[0]
            money -= kabu*A[0]
            money += kabu*A[1]
            return money
        else:
            return 1000

    l = []
    kabu = 0
    if A[1] > A[0]:
        ascending = True
        kabu = money // A[0]
        money -= kabu*A[0]
    else:
        ascending = False
    for i in range(len(A)-1):
        #print(A[i],kabu,money)
        if ascending:  #上昇中
            if A[i] > A[i+1]:
                #下降に転じたので売り
                if kabu > 0:
                    money += kabu*A[i]
                    kabu = 0
                    ascending = False
                else:
                    pass
            else:
                continue
        else:  #下降中
            if A[i] < A[i+1]:
                #上昇したので買い
                assert kabu == 0
                kabu = money // A[i]
                money -= kabu*A[i]
                ascending = True
            else:
                continue
    if kabu > 0:
        money += kabu*A[-1]
        kabu = 0
    return money
if __name__ == "__main__":
    ret = main()
    print(ret)
A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())

if A < B:
	if A + (V*T) >= B + (W*T):
		print("YES")
	else:
		print("NO")
else:
	if A - (V*T) <= B - (W*T):
		print("YES")
	else:
		print("NO")


### FIXED CODE ###

S = input()

print(S[:3])
print(N)

S = [input() for i in range(N)]
print(S)

ac = 0
wa = 0
tle = 0
re = 0
for i in range(N):
    if S[i] == 'AC':
        ac += 1
    elif S[i] == 'WA':
        wa += 1
    elif S[i] == 'TLE':
        tle += 1
    elif S[i] == 'RE':
        re += 1

print('AC x' , ac)
print('WA x' ,wa)
print('TLE x' ,tle)
print('RE x' , re)  

### FIXED CODE ###

N = int(input())
#print(N)

S = [input() for i in range(N)]
#print(S)

ac = 0
wa = 0
tle = 0
re = 0
for i in range(N):
    if S[i] == 'AC':
        ac += 1
    elif S[i] == 'WA':
        wa += 1
    elif S[i] == 'TLE':
        tle += 1
    elif S[i] == 'RE':
        re += 1

print('AC x' , ac)
print('WA x' ,wa)
print('TLE x' ,tle)
print('RE x' , re)