Harryxun/stf_run huggingface dataset:
from fractions import gcd

MOD = 10 ** 9 + 7

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

tmp = 1
for a in A:
    tmo *= a // gcd(tmp, a)

ans = 0
for a in A:
    ans += (tmp // a) % MOD
    ans %= MOD

print (ans)
    

### FIXED CODE ###

def main():
    from fractions import gcd

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

    MOD = 10 ** 9 + 7

    tmp = 1
    for a in A:
        tmp *= a // gcd(tmp, a)

    ans = 0
    for a in A:
        ans += tmp // a
    ans %= MOD

    print (ans)

if __name__ == '__main__':
    main()
# -*- coding: utf-8 -*-
import math
x, y = map(int,input().split())

if (2 * y - x) % 3 != 0 and (2 * x - y) % 3 != 0:
    print(0)
else:
    a = (2 * y - x) // 3
    b = (2 * x - y) // 3
    ans = math.factorial(a + b) / (math.factorial(a) * math.factorial(b))
    print(int(ans) % (pow(10, 9) + 7))


### FIXED CODE ###

# -*- coding: utf-8 -*-
#コンビネーション
def cmb(n, r):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % mod

N = 10 ** 6  # N は必要分だけ用意する
mod = pow(10, 9) + 7
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod // i)) % mod)
    factinv.append((factinv[-1] * inv[-1]) % mod)

import math
x, y = map(int,input().split())

if (2 * y - x) % 3 != 0 and (2 * x - y) % 3 != 0:
    print(0)
else:
    a = (2 * y - x) // 3
    b = (2 * x - y) // 3
    ans = cmb(a+b, a)
    print(ans % (pow(10, 9) + 7))
k = int(input())
a, b = list(map(int, input().split()))
flg = False
for i in range(a, b+1):
  if i % k == 0:
    print("OK")
    flg = True
    break
print("NO") if not(flg)

### FIXED CODE ###

k = int(input())
a, b = list(map(int, input().split()))
flg = False
for i in range(a, b+1):
  if i % k == 0:
    flg = True
    break
if flg:
  print("OK")
else:
  print("NG")
N = input()

s = int(N[len(N)-3])*100+int(N[len(N)-2])*10+int(N[len(N)-1])
if(s==0):
  print(0)
else: 
  print(1000-s)

### FIXED CODE ###

N = input()
if(int(N)>=100):
  s = int(N[len(N)-3])*100+int(N[len(N)-2])*10+int(N[len(N)-1])
else:
  s = int(N)
if(s==0):
  print(0)
else: 
  print(1000-s)
from fractions import gcd
N = int(input())
arr = []

def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]


for i in range(N):
    arr.append(list(map(int, input().split())))

C = []
for i in range(N):
    for j in range(N):
        if i < j:
            x = arr[i][0]-arr[j][0]
            y = arr[i][1]-arr[j][1]
            g = gcd(x, y)
            x = int(x / g)
            y = int(y / g)
            C.append([x, y])

C = get_unique_list(C)
S = [0 for i in range(len(C))]

for c in range(len(C)):
    tmp = []
    for i in range(N):
        if C[c][0] != 0:
            tmp.append(round(arr[i][1] - arr[i][0]/C[c][0]*C[c][1],10))
        else:
            tmp.append(round(arr[i][0] - arr[i][1]/C[c][1]*C[c][0],10))
    tmp = list(set(tmp))
    S[c] = len(tmp)

print(min(S))


### FIXED CODE ###

import sys
N = int(input())
arr = []

for i in range(N):
    arr.append(list(map(int, input().split())))

if N == 1:
    print(1)
    sys.exit()

d = {}

for i in range(N):
    for j in range(N):
        if i != j:
            x = arr[i][0] - arr[j][0]
            y = arr[i][1] - arr[j][1]
            if (x, y) in list(d.keys()):
                d[(x, y)] += 1
            else:
                d[(x, y)] = 1

print(N - max(list(d.values())))
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 18 21:48:15 2018

@author: nakag
"""
n = int(raw_input())
print(n)
#1からNまでで因数分解を行う
ans_lst = []

import math
for j in range(1,n+1):
    I=int(j)
    s=0
    R=int(I)
    L=[]
    while s==0:
        #R=int(math.sqrt(R))
        for i in range(2,R+1):
            if I%i==0:
                I=I/i
                if I==1:
                    s=1
                L.append(i)
                break
    print(len(L))

    #素数の数に応じて場合分け
    if len(L)==1:
        if L[0]**3 == j:
            ans_lst.append(1)
    
    elif len(L)==2:
        #約数が8のときとりえる場合の積を数える
        s1 = L[0] * L[1]**3
        s2 = L[0]**3 * L[1]
        if s1 == j:
            ans_lst.append(1)
        elif s2 ==j:
            ans_lst.append(1)
    elif len(L) ==3:
        s3 = L[0] * L[1] * L[2]
        if s3 == j:
            ans_lst.append(1)
    
    print(ans_lst)



### FIXED CODE ###

l = map(int, raw_input().split())
#print(l)

s = (l[0] - 1) * (l[1] - 1)
print(s)
S = input()
max_c = 0
for i in S:
    if i != 'R':
        count = 0
    else:
        count = count + 1
    
    if max_c < count:
        max_c = count
    
print(max_c)

### FIXED CODE ###

S = input()
count = 0
max_c = 0

for i in S:
    if i != 'R':
        count = 0
    else:
        count = count + 1
    
    if max_c < count:
        max_c = count
    
print(max_c)
a,b,c,x,y = map(int,input().split())
l = 0

if x > y:
    l += (x - y) * a
    p = y
elif x < y:
    l += (y - x) * b
    p = x
else:
    pass
l += p * 2 * c
n = max(x,y) * 2 * c
m = x * a + y * b
print(min(l,n,m))

### FIXED CODE ###

a,b,c,x,y = map(int,input().split())
l = 0
p = x

if x > y:
    l += (x - y) * a
    p = y
elif x < y:
    l += (y - x) * b
    p = x
else:
    pass
l += p * 2 * c
n = max(x,y) * 2 * c
m = x * a + y * b
print(min(l,n,m))
n = int(input())
h = list(map(int, input().split()))
a = []
ans = 0
for i in range(1,n):
    if h[i-1]>=h[i]:
        ans+=1
    else:
        a.append(ans)
        ans=0
    if i==n-1:
        a.append(ans)
a.sort(reverse=True)
print(a[0])

### FIXED CODE ###

n = int(input())
h = list(map(int, input().split()))
a = [0]
ans = 0
for i in range(1,n):
    if h[i-1]>=h[i]:
        ans+=1
    else:
        a.append(ans)
        ans=0
    if i==n-1:
        a.append(ans)
a.sort(reverse=True)
print(a[0])
def gcd(p, q):
    if p < q:
        p, q = q, p
    while q > 0:
        p, q = q, p%q
    return p

n = int(input())
ans = 1
for i in range(n):
  t = int(input())
  ans = a*t//gcd(a, t)
print(ans)

### FIXED CODE ###

def gcd(p, q):
    if p < q:
        p, q = q, p
    while q > 0:
        p, q = q, p%q
    return p

n = int(input())
ans = 1
for i in range(n):
  t = int(input())
  ans = ans*t//gcd(ans, t)
print(ans)
n,m = map(int, input().split())
A = list(map(int, input().split()))

rem_cnts = {}
curr_sum_rem = 0
for a in A:
    curr_sum_rem += a
    curr_sum_rem%=m
    rem_cnts.setdefault(curr_sum_rem,0)
    rem_cnts[curr_sum_rem] += 1

ans = 0
for cnt in rem_cnts.values():
    ans += cnt*(cnt-1)//2
ans += rem_cnts[0]

print(ans)

### FIXED CODE ###

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

rem_cnts = {0:0}
curr_sum_rem = 0
for a in A:
    curr_sum_rem += a
    curr_sum_rem%=m
    rem_cnts.setdefault(curr_sum_rem,0)
    rem_cnts[curr_sum_rem] += 1

ans = 0
for cnt in rem_cnts.values():
    ans += cnt*(cnt-1)//2
ans += rem_cnts[0]

print(ans)
N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))
BC = [None] * M
for i in range(M):
    BC[i] = tuple(map(int, input().split()))
BC.sort(key=lambda tpl: tpl[1], reverse=True)  # sort by C descendant

D = [0] * N
i = 0
j = 0
while i < N and j < M:
    b, c = BC[j]
    for k in range(i, min(i + b, N)):
        D[k] = c
    i += b
    j += 1

for i in range(N):
    A[i] = max(A[i], D[i])

print(sum(A))


### FIXED CODE ###

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


def f():
    if A <= 5:
        return 0
    elif 6 <= A <= 12:
        return B // 2
    else:
        return B


print(f())
N = int(input())
X = list(map(int, input().split()))
Min = min(X)
Max = max(X)
disList = []
for ass in range(Min, Max):
  dis = 0
  for person in range(N):
    dis += (X[person] - ass) * (X[person] - ass)
  disList.append(dis)
print(min(disList))

### FIXED CODE ###

N = int(input())
X = list(map(int, input().split()))
costMin = 9999999999
for locate in range(1, 101):
  cost = 0
  for i in range(N):
    cost += (X[i]-locate)**2
  if cost < costMin:
    costMin = cost
print(costMin)
word1 = list(input())
word2 = ""
for c in word1:
    if c == "9":
        word2 += "1"
    else if c == "1":
        word2 += "9"
    else:
        word2 += c
print(word2)


### FIXED CODE ###

word1 = list(input())
word2 = ""
for c in word1:
    if c == "9":
        word2 += "1"
    elif c == "1":
        word2 += "9"
    else:
        word2 += c
print(word2)
def Main(N, K, P):
    wa = sum(P[:K])
    max_sum = wa
    max_sum_ind = 0
    for i in range(N-K):
        wa = wa - P[i] + P[i+K]
        if(wa > max_sum):
            max_sum = wa
            max_sum_ind = i
    ans = 0
    for i in range(max_sum_ind+1, max_sum_ind+K+1):
        ans += (P[i]+1)/2
    return ans

def main():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))
    print("{:.12f}".format(Main(N, K, P)))

if __name__ == '__main__':
    main()

### FIXED CODE ###


def Main(N, K, P):
    wa = sum(P[:K])
    max_sum = wa
    max_sum_ind = 0
    for i in range(N-K):
        wa = wa - P[i] + P[i+K]
        if(wa > max_sum):
            max_sum = wa
            max_sum_ind = i
    ans = 0
    if max_sum_ind == 0:
        for i in range(K):
            ans += (P[i]+1)/2
    else:
        for i in range(max_sum_ind+1, max_sum_ind+K+1):
            ans += (P[i]+1)/2
    return ans

def main():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))
    print("{:.12f}".format(Main(N, K, P)))

if __name__ == '__main__':
    main()
N = int(input())
a = list(map(int, input().split()))
from collections import deque
kisuu = deque([])
bai4 = deque([])
sonota = deque([])
for ai in a:
    if ai % 4 == 0:
        bai4.append(ai)
    elif ai % 2 == 0:
        sonota.append(ai)
    else:
        kisuu.append(ai)

ans = deque([])
if kisuu:
    s = kisuu.pop()
    ans.append(s)
elif sonota:
    s = sonota.pop()
    ans.append(s)
else:
    s = bai4.pop()
    ans.append(s)        

for i in range(1, N + 1):
    if i == N:
        print('Yes')
        quit()
    if ans[i - 1] % 2 == 1:
        if bai4:
            s = bai4.pop()
            ans.append(s)
        else:
            break
    elif ans[i - 1] % 2 == 0 and ans[i - 1] % 4 != 0:
        if sonota:
            s = sonota.pop()
            ans.append(s)
        elif bai4:
            s = sonota.pop()
            ans.append(s)
        else:
            break
    elif ans[i - 1] % 4 == 0:
        if kisuu:
            s = kisuu.pop()
            ans.append(s)
        elif sonota:
            s = sonota.pop()
            ans.append(s)
        elif bai4:
            s = sonota.pop()
            ans.append(s)
        else:
            break
print('No')           

### FIXED CODE ###

N = int(input())
a = list(map(int, input().split()))
from collections import deque
kisuu = deque([])
bai4 = deque([])
sonota = deque([])
for ai in a:
    if ai % 4 == 0:
        bai4.append(ai)
    elif ai % 2 == 0:
        sonota.append(ai)
    else:
        kisuu.append(ai)

ans = deque([])
if kisuu:
    s = kisuu.pop()
    ans.append(s)
elif sonota:
    s = sonota.pop()
    ans.append(s)
else:
    s = bai4.pop()
    ans.append(s)        

for i in range(1, N + 1):
    if i == N:
        print('Yes')
        quit()
    if ans[i - 1] % 2 == 1:
        if bai4:
            s = bai4.pop()
            ans.append(s)
        else:
            break
    elif ans[i - 1] % 2 == 0 and ans[i - 1] % 4 != 0:
        if sonota:
            s = sonota.pop()
            ans.append(s)
        elif bai4:
            s = bai4.pop()
            ans.append(s)
        else:
            break
    elif ans[i - 1] % 4 == 0:
        if kisuu:
            s = kisuu.pop()
            ans.append(s)
        elif sonota:
            s = sonota.pop()
            ans.append(s)
        elif bai4:
            s = bai4.pop()
            ans.append(s)
        else:
            break
print('No')
a = list(map(int,input().split()))
b = list(map(int,input().split()))

b.sort(reverse=True)
for i in  range(a[1]):
        del b[0]
    print(sum(b))

### FIXED CODE ###

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

if len(b) <= a[1]:
    print("0")
elif a[1]==0:
    print(sum(b))
else:
    b.sort(reverse=True)
    print(sum(b[a[1]:]))
mod = 998244353

N, S, *A = map(int, open(0).read().split())

dp = [1] + [0] * S
for i, a in enumerate(A):
    for j in reversed(range(S + 1)):
        dp[j] = 2 * dp[j] + dp[j - a] * (j >= a)

print(dp[S])

### FIXED CODE ###

mod = 998244353

N, S, *A = map(int, open(0).read().split())

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

for i, a in enumerate(A):
    for j in range(S + 1):
        dp[i + 1][j] += 2 * dp[i][j]
        dp[i + 1][j] %= mod

        if j + a <= S:
            dp[i + 1][j + a] += dp[i][j]
            dp[i + 1][j + a] %= mod

print(dp[N][S])
from collections import Counter
n = int(input())
a = [int(i) for i in input().split()]
k = Counter(a)
b = list(k.values())
over_2 = [bb for bb in b if bb >= 2]
if sum(over_2) % 2 == 1:
    print(len(b))
else:
    if len(over_2 == 0):
        print(len(b))
    else:
        print(len(b) - 1)

### FIXED CODE ###

from collections import Counter
n = int(input())
a = [int(i) for i in input().split()]
k = Counter(a)
b = list(k.values())
b = [1 if bb % 2 == 1 else 2 for bb in b]
over_2 = [bb for bb in b if bb >= 2]
if len(over_2) == 0:
    print(len(b))
elif len(over_2) % 2 == 0:
    print(len(b))
else:
    print(len(b) - 1)
import numpy as np

N, W = map(int, input().split())
dp = np.array([ [0]*(W+1) ] * (N+1))
wv = [[0,0]]
for n in range(1,N+1):
    w, v = map(int, input().split() )
    dp[n][w:W+1] = max(dp[n-1][w:W+1], dp[n-1][W+1-w]+v )
    # for w_lim in range(1,W+1):
    #     if w_lim - wv[n][0] >= 0 :
    #         dp[n][w_lim] = max( dp[n-1][w_lim], dp[n-1][w_lim-wv[n][0]]+wv[n][1] )
    #     else :
    #         dp[n][w_lim] = dp[n-1][w_lim]
print(dp[N][W])


### FIXED CODE ###

import numpy as np

N, W = map(int, input().split())
dp = np.array([ [0]*(W+1) ] * (N+1))
for n in range(1,N+1):
    w, v = map(int, input().split() )
    dp[n][:] = dp[n-1][:]
    dp[n][w:W+1] = np.maximum(dp[n-1][w:W+1], dp[n-1][:W+1-w]+v )
    # for w_lim in range(1,W+1):
    #     if w_lim - wv[n][0] >= 0 :
    #         dp[n][w_lim] = max( dp[n-1][w_lim], dp[n-1][w_lim-wv[n][0]]+wv[n][1] )
    #     else :
    #         dp[n][w_lim] = dp[n-1][w_lim]
print(dp[N][W])
from collections import Counter
N = int(input())
A = list(map(int, input().split()))

c = Counter(A)
A = [i[0] for i in c.items() if i[1] == 1]

A.sort()
ans = 0
i = 0
j = len(A)-1

while A:
  if A[j] % A[i] == 0:
    A.pop(j)
  j -= 1
  if j == i:
    ans += 1
    j = int(len(A)-1)
    i += 1
  if j == i:
    ans += 1
    break;

print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
l = max(A)+1
li = [0]*(l)
A.sort()

for a in A:
  if li[a] == 0:
    li[a] = 1
    for i in range(a*2, l, a):
      li[i] = 2
  elif li[a] == 1:
    li[a] = 2
print(li.count(1))
i=list(int,input().split())
if i[0]*i[1]>i[2]:
    print(i[0]*i[1])
elif:
    print(i[2])

### FIXED CODE ###


i=list(map(int,input().split()))
if i[2]>i[0]*i[1]:
    print(i[0]*i[1])
else:
    print(i[2])
N = int(input())
A = list(map(int, input().split())
         
A.sort()

mod = A[-1] % A[-2]

print(A[0] - mod)

### FIXED CODE ###

import functools
import math
import fractions

N = int(input())
A = list(map(int, input().split()))
         
a = functools.reduce(fractions.gcd, A)
print(a)
L = [int(input()) for i in range(len("abcde"))]
k = int(input())

for i in range(5):
  for j in range(i, 5):
    if abs(L[i] - L[i+j+1]) > k:
      print(":(")
      break
  else:
    continue
  break
else:
  print("Yay!")



### FIXED CODE ###

L = [int(input()) for i in range(len("abcde"))]
k = int(input())

for i in range(4):
    for j in range(i+1, 5):
        if abs(L[i] - L[j]) > k:
            print(":(")
            break
    else:
        continue
    break
else:
    print("Yay!")
a, b, c = [int(i) for i in input().split()]
nums = 0
for i in range(a,c+1)
    if b%i ==0 and c%i ==0:
        nums = nums + 1
    else:
        pass
   
print(nums)

### FIXED CODE ###

a, b, c = [int(i) for i in input().split()]
nums = 0
for i in range(a, b + 1):
    if c%i == 0:
        nums = nums + 1
    else:
        pass
print(nums)
def main():
    n = int(input())
    c = []
    mod = 10 ** 9 + 7
    state = [0 for i in range(n+10)]
    dp = [0 for i in range(n+1)]
    dp[0] = 1
    for i in range(n):
        c_i = int(input())

        if state[c_i] >= 1 and state[c_i] != i:
            dp[i+1] = (dp[state[c_i]] + dp[i]) % mod
        else:
            dp[i+1] = dp[i] % mod

        state[c_i] = i + 1
    print(dp[-1] % mod)

main()


### FIXED CODE ###

def main():
    n = int(input())
    c = []
    mod = 10 ** 9 + 7
    state = [0 for i in range(n+200000)]
    dp = [0 for i in range(n+1)]
    dp[0] = 1
    for i in range(n):
        c_i = int(input())

        if state[c_i] >= 1 and state[c_i] != i:
            dp[i+1] = (dp[state[c_i]] + dp[i]) % mod
        else:
            dp[i+1] = dp[i] % mod

        state[c_i] = i + 1
    print(dp[-1] % mod)

main()
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, a, b, c, d = list(map(int, readline().split()))
    if s[c-1] == "#" or s[d-1] == "#":
        print("No")
    else:
        s = str(readline().rstrip().decode('utf-8'))
        wrc = 0
        brc = 0
        wc = 0
        bc = 0
        for i in range(n):
            if s[i] == "#":
                bc += 1
                wc = 0
            else:
                bc = 0
                wc += 1
            wrc = max(wrc, wc)
            brc = max(brc, bc)
        if c < d:
            if brc < 2:
                print("Yes")
            else:
                print("No")
        else:
            if brc >= 2 and wrc >= 3:
                print("Yes")
            else:
                print("No")


if __name__ == '__main__':
    solve()


### FIXED CODE ###

import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, a, b, c, d = list(map(int, readline().split()))
    s = str(readline().rstrip().decode('utf-8'))
    if c == d:
        print("No")
    elif c < d:
        print("Yes" if s[a-1:d+1].count("##") == 0 else "No")
    elif c > d:
        print("Yes" if s[a-1:c+1].count("##") == 0 and s[b-2:d+1].count("...") != 0 else "No")


if __name__ == '__main__':
    solve()
import sys
import re

l = sys.stdin.readline()
l = int(l)
out = []
def x(stri,l,depth):
  str = 'abcdefghij'
  for i in range(0,l-depth+1):
    cdepth = depth
    cstri = stri
    cstri += str[i] 
    cdepth -= 1
    if( cdepth == 0):
	out.append(cstri)
    else:
	x(cstri,l,cdepth)


stri = 'a'
if( l == 1):
 print stri
 exit(0)
x(stri,l,l-1)

ret = {}
count = 0
for i in out:
  prev = '0'
  moji = ""
  for j in i:
    if( prev == j ):
      moji += "E"
    else:
      if( prev > j ):
        moji += "U"
      else:
        moji += "D"
    prev = j
  ret[count] = moji
  count += 1
 
count = 0
kekka = {}
for i in out:
  if( ret[count] not in kekka.values()):
    print i
  kekka[count] = ret[count]
  count += 1


sys.stdout.flush()


### FIXED CODE ###

import sys
import re

l = sys.stdin.readline()
l = int(l)
out = []
def x(stri,l,depth):
  str = 'abcdefghij'
  use = 0
  for i in range(0,l-depth+1):
    if( use == 1):
      break
    cdepth = depth
    cstri = stri
    if ( str[i] not in cstri):
      use = 1
    cstri += str[i] 
    cdepth -= 1
    if( cdepth == 0):
	out.append(cstri)
    else:
	x(cstri,l,cdepth)


stri = 'a'
if( l == 1):
 print stri
 exit(0)
x(stri,l,l-1)

count = 0
for i in out:
  print i


sys.stdout.flush()
k,s = map(int,input().split())

count = 0
num = range(k+1)
for x in num:
  for y in num:
    if x + Y > s:
      break:
    for z in num:
      if x + y + z == s:
        count += 1
      elif x + y + z > s:
        break:

print(count)

### FIXED CODE ###

k,s = map(int,input().split())

count = 0
for x in range(k+1):
  for y in range(k+1):
    a = s - x - y
    if a >= 0 and a <= k:
      count += 1

print(count)
N = int(input())
A = list(map(int, input().split()))
if N == 0 and A[0] == 1:
    print(1)
else:
    nodes = [0]*(N+1)
    s_d = 0 # 飽和してないノードが残ってる深さ
    cap_d = 1 - A[0]
    failed = False
    for i, a in enumerate(A):
        # a個の葉をなるべく浅いノードから取る
        while a > 0:
            # これ以上分岐することろがなければ失敗
            if i < s_d or cap_d <= 0:
                failed = True
                break
            # s_dから枝を取れるだけ取る
            x = min(cap_d - nodes[s_d], a)
            a -= x
            nodes[s_d:i+1] = [node + x for node in nodes[s_d:i+1]]
            # s_dがいっぱいになったら深さを一つ進める
            if nodes[s_d] >= cap_d:
                cap_d -= A[s_d]
                cap_d *= 2
                s_d += 1
        if failed:
            break
    print(-1 if failed else sum(nodes))

### FIXED CODE ###

H1, M1, H2, M2, K = list(map(int, input().split()))
print(H2*60 + M2 - K - H1*60 - M1)
def resolve():
    '''
    code here
    '''
    import string
    S = input()

    if S == "zyxwvutsrqponmlkjihgfedcba":
        print(-1)
    else:
        if len(S) < 26:
            temp_str = [item for item in string.ascii_lowercase]
            for item in S:
                temp_str.remove(item)
            print(S+temp_str[0])
            
        else:
            temp_str = [item for item in string.ascii_lowercase]
            temp_str.remove(S[0])
            for i in range(1,26):
                if ord(S[i-1])+1 >= ord(S[i]):
                    temp_str.remove(S[i])
                else:
                    temp_index = i
                    break
                
            temp_index = i

            print(S[:temp_index-1] + temp_str[0])


if __name__ == "__main__":
    resolve()


### FIXED CODE ###

def resolve():
    '''
    code here
    '''
    import string
    S = [item for item in input()]
    temp_abc = [item for item in string.ascii_lowercase]

    if len(S) < 26:
        for item in S:
            temp_abc.remove(item)
        res = ''.join(S) + temp_abc[0] 

    else:
        if S == temp_abc[::-1]:
            res = -1
        else:
            tail_inorder = []
            prev = 'a'
            cnt = 0
            for item in S[::-1]:
                if item >= prev:
                    tail_inorder += [item]
                    cnt += 1
                else:
                    break
                prev = item
            end_letter = S[-1*(cnt+1)]
            tail_inorder.sort()
            for item in tail_inorder:
                if end_letter < item:
                    res_end_letter = item
                    break

            res = S[:-1*(cnt+1)] + [res_end_letter]
    print(''.join(res)) if res != -1 else print(res)

if __name__ == "__main__":
    resolve()
#import
#import math
#import numpy as np
#= int(input())
#= input()
N, W = map(int, input().split())
#= list(map(int, input().split()))
#= [input(), input()]

x = [list(map(int, input().split())) for _ in range(N)]

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

for i in range(1, N + 1):
    for j in range(1, W + 1):
        dp[i][j] = dp[i - 1][j]
        if i != 0 and x[i - 1][0] <= j:
            dp[i][j] = max(dp[i][j], dp[i-1][j-x[i-1][0]] + x[i-1][1])

print(dp[-1][W])


### FIXED CODE ###

#import
#import math
#import numpy as np
#= int(input())
#= input()
N, W = map(int, input().split())
#= list(map(int, input().split()))
#= [input(), input()]

x = [list(map(int, input().split())) for _ in range(N)]

dp = [[10**10] * (10 ** 5 + 10) for _ in range(N + 1)]

dp[0][0] = 0

#  i:N個目 j:価値

for i, (w, v) in enumerate(x, 1):
    for j in range(10**5 + 1):
        dp[i][j] = dp[i - 1][j]
        if j != 0 and v <= j:
            dp[i][j] = min(dp[i][j], dp[i - 1][j - v] + w)

for i in range(10 ** 5, -1, -1):
    if dp[-1][i] <= W:
        print(i)
        exit()