peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
N=int(input())
task=[[]]*N
for i in range(N):task[i]=list(map(int,input().split()))
task.sort(key=lambda x: x[1])
t=0
for i in range(N):
    t+=task[i][0]
    if task[i][1]<t:
        print('No')
        exit()
print('Yes')
# Judge status: Wrong Answer
import itertools
import math
n=int(input())
a=list(map(int,input().split()))
ave=round(sum(a)/n)
#print(ave)
count=0
for i in range(n):
	count+=(a[i]-ave)**2
print(count)
print(round(-1.6))
# Judge status: Accepted
n = int(input())
h = [int(i) for i in input().split()]
dp = [10 ** 5 for _ in range(n)]
dp[0] = 0

for i in range(1, n):
    if i == 1:
        dp[i] = abs(h[1] - h[0])
    else:
        dp[i] = min(dp[i-2] + abs(h[i-2] - h[i])
                    , dp[i-1] + abs(h[i-1] - h[i]))
print(dp[n-1])
# Judge status: Accepted
s=input()

sl=len(s)+1
l=[0]*sl

for i in range(sl-1):
  if s[i]=="<":
    l[i+1]=l[i]+1
    
for i in range(sl-2,-1,-1):
  if s[i]==">":
    l[i]=max(l[i+1]+1, l[i])
    
print(sum(l))
# Judge status: Accepted
import re
import copy

def accept_input():
    N = input()
    return int(N)

N = accept_input()

power = 1
for i in range(1,N+1):
    power = (power * i)%(10**9+7)
print(power)
# Judge status: Accepted
import sys
n = int(input())
ls = []
for i in range(n):
    a, b = [int(i) for i in sys.stdin.readline().split()]
    ls.append([a, b])
_sum = 0
for a, b in ls[::-1]:
    if (a + _sum) % b:
        _sum += (b - (a + _sum) % b)
print(_sum)
# Judge status: Accepted
import math
a,b = map(int,input().split())
s = 0
l = [ list(map(int,input().split(" "))) for i in range(a)]
for i in range(a):
  if math.sqrt(l[i][0]**2+l[i][1]**2)<=b:
    s = s+1
print(s)
# Judge status: Wrong Answer
N=int(input())
no = True
for i in range(1,10):
  for k in range(1,i+1):
    if N==i*k:
      print('Yes')
      no = False
      break
if no:
  print('No')
# Judge status: Accepted
n, k, s = map(int, input().split())

a = []

for i in range(k):
    a.append(s)

for i in range(n-k):
    if s == 1:
        a.append(2)
    else:
        a.append(s-1)

print(*a)
# Judge status: Accepted
N, M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]
AB.sort()

ans = 0
for i in range(N):
  #まだ足りないケース
  if M > AB[i][1]:
    ans += AB[i][0] * AB[i][1]
    M -= AB[i][1]
  else:
    ans += AB[i][0] * M
    break
print(ans)
# Judge status: Accepted
n = sum([int(i) for i in list(input())])
if n % 9 == 0:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import numpy as np
N = int(input())
A = np.array(tuple(map(int, input().split())), dtype=np.int64) - np.arange(N) - 1
median = np.median(A)
print(int(min(np.abs(A - median + 0.5).sum(), np.abs(A - median - 0.5).sum())) if int(median * 2) & 1 else int(np.abs(A - median).sum()))
# Judge status: Wrong Answer
from math import floor
from bisect import bisect_left
N, K = map(int,input().split())
A = list(map(int,input().split()))
def chk(L):
    cnt = 0
    for i in range(N):
        cnt += floor(A[i]/L)
    return cnt <= K
l, r = 1, max(A)
for _ in range(1000):
    m = (l+r)/2
    if chk(m):
        r = m
    else:
        l = m
print(round(m))
# Judge status: Accepted
a,b = input().split(" ")
a,b = int(a),int(b)
ab = a + b
if ab % 2 != 0:
    print(int((a+b+1)/2))
else:
    print(int((a+b)/2))
# Judge status: Wrong Answer
a,b=map(int,input().split())
c=1
d=0
while c<d:
    d+=1
    c=a*c-(d-1)
print(d)
# Judge status: Accepted
N = int(input())
A = [int(i) for i in input().split()]

result = []
res = A[1]
for a in A[2:N]:
    res ^= a
result.append(str(res))

for i in range(0, N-1):
    res = A[i] ^ A[i+1] ^ res
    result.append(str(res))

print(" ".join(result))
# Judge status: Wrong Answer
H, N = map(int, input().split())

inf = float('inf')
dp = [inf] * (H + 1)
dp[0] = 0
for i in range(N):
    A, B = map(int, input().split())
    for j in range(H):
        t1 = j + A
        if t1 > H:
            t1 = H
        t2 = dp[t1]
        if t2 == inf:
            continue
        t2 += B
        if t2 < dp[t1]:
            dp[t1] = t2
print(dp[H])
# Judge status: Wrong Answer
a, b, c, x, y = map(int, input().split())
l = []

for i in range(x+y):
    if i%2!=0:
        continue
    if (i//2)>=x:
        a_p = 0
        b_p = b*(y-(i//2))
    if (i//2)>=y:
        a_p = a*(x-(i//2))
        b_p = 0
    else:
        a_p = a*(x-(i//2))
        b_p = b*(y-(i//2))
        
    price = (c*i)+ a_p + b_p
    l.append(price)

print(min(l))
# Judge status: Accepted
n,k = map(int,input().split())
if n %k ==0:
    print(0)
else :
    print(1)
# Judge status: Accepted
k=10**9;x,y=divmod(-int(input()),k);print(0,0,1,k,-x,y)
# Judge status: Accepted
H=int(input())
W=int(input())
N=int(input())

m = max(H,W)
print(-(-N // m))
# Judge status: Wrong Answer
W, a, b = map(int,input().split())
if b > a+W:
    print(b-(a+W))
elif b <= a+W and b+W >= a:
    print(0)
else:
    print(b+W-a)
# Judge status: Wrong Answer
a,b=map(int, input().split())
c="必要な電源タップ数は"
d="個です。"
count=0
total=0
while True:
    
#    total+=a
    
#    if total<b:
#        total-=1
#        count+=1
#    else:
#        break
    if total >= b:
        break
    total += (a-1)
    count+=1
print(count)
# Judge status: Accepted
n,k = (int(a) for a in input().split())
s = input()
x =list(s)
x[k-1] = x[k-1].lower()
print(''.join(x))
# Judge status: Accepted
input_line = input().split(' ')
numA = int(input_line[0])
numB = int(input_line[1])

def gcd(a, b):
  if b > a:
    tmp = b
    b = a
    a = tmp
  while True:
    rem = a % b
    if rem == 0:
      break
    else:
      a = b
      b = rem
  return b

gcd = gcd(numA, numB)
divA = numA // gcd
divB = numB // gcd

print(gcd * divA * divB)
# Judge status: Accepted
N, K = map(int, input().split())
arr = list(map(int, input().split()))
def f(x):
    res = 0
    for i in range(N):
        if arr[i] % x != 0:
            res += arr[i]//x
        else:
            res += max((arr[i]//x)-1,0)
    return res
left = 0
right = max(arr)
while abs(left-right) > 1:
    tmp = (left+right)//2
    if f(tmp) > K:
        left = tmp
    else:
        right = tmp
print(right)
# Judge status: Wrong Answer
import collections
n=int(input())
s=list(input())
s=collections.Counter(s)
ans=1
for i in s:
  ans*=s[i]+1
print(ans-1)
# Judge status: Accepted
from collections import Counter
N=int(input())
A=list(map(int,input().split()))
four=0
two=[]
numbers=Counter(A)
for key,value in numbers.items():
    if value>=4:
        four=max(four,key**2)
    if value>=2:
        two.append(key)
sorted_two=sorted(two)
if four==0 and len(sorted_two)<=1:
    print(0)
else:
    print(max(four,sorted_two[-1]*sorted_two[-2]))
# Judge status: Accepted
d = int(input())
a = 'Christmas'
b = ' Eve'
if d == 25:
    print(a)
elif d == 24:
    print(a + b)
elif d == 23:
    print(a + b * 2)
else:
    print(a + b * 3)
# Judge status: Accepted
n,m=map(int,input().split())
a=list(map(int,input().split()))
bc=[list(map(int,input().split())) for i in range(m)]
a.sort()
bc.sort(key=lambda x: x[1],reverse=True)
# print(a)
# print(bc)
i=0
for b,c in bc:
  tb=b
  while tb>0:
    if n==i:
      break
    if a[i]>=c:
      break
    a[i]=c
    tb-=1
    i+=1
  if n==i:break
  if a[i]>=c :
    break
print(sum(a))
# Judge status: Wrong Answer
a,sums=list(map(int,input().split()))
if a*3==sums:
  print(1)
else:
  ret=0
  mai=2 if sums%3==0 & sums // 3 <= a else 0
  for x in range(a+1):
    if sums-x <2*a:
      for y in range(a+1):
        if sums-x-y<a:
          if (sums-x-y == x) | (sums-x-y == y):
            ret+=1
          else:
            ret+=2
    if sums-x == 2*a:
      ret+=1
  print(ret-mai)
# Judge status: Wrong Answer
s = list(input())
ans = [0]*(len(s))

for i in range(len(s)):
  if i%2 == 0:
    if s[i] == 'R' or s[i] == 'U' or s[i] == 'D':
      ans[i] = 1
  else:
    if s[i] == 'L' or s[i] == 'U' or s[i] == 'D':
      ans[i] = 1

if len(set(ans)) == 2:
  print('No')
else:
  print('Yes')
# Judge status: Accepted
N = int(input())

n = N//1000
if n * 1000 != N:
    n += 1
print(1000*(n)-N)
# Judge status: Accepted
l=str(input())
n=0
for i in range(len(l)):
  if i%2==0 and l[i]=='0':
    n+=1
  if i%2==1 and l[i]=='1':
    n+=1
print(min(n,len(l)-n))
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline
# int(input()) # 入力が1つ
r, g, b = map(int, input().split()) # 入力が複数
# [int(i) for i in input().split()] # 配列で数字

t = r ** 100 + g * 10 + b
if t % 4 == 0:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
from math import gcd
K = int(input())
 
c = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        k = gcd(i,j)
        for l in range(1,K+1):
            a = gcd(k, l)
            c += a
print(c)
# Judge status: Accepted
n, d = map(int, input().split())
ans = 0
for i in range(n):
    a, b = map(int, input().split())
    if a**2 + b**2 <= d**2:
        ans += 1
print(ans)
# Judge status: Accepted
s = input()
ans = 0
for i in range(len(s) // 2):
    if s[i] != s[-i-1]:
        ans+=1 
print(ans)
# Judge status: Accepted
def myAnswer(N:int,P:list) -> str:
   flag = False
   for i in range(N):
      if(i+1 != P[i]):
         if(flag):
            return "NO"
         flag = True
         P[P.index(i + 1)] = P[i]
         P[i] = i + 1
   return "YES"

def modelAnswer():
   return
def main():
   N = int(input())
   P = list(map(int,input().split()))
   print(myAnswer(N,P))
if __name__ == '__main__':
   main()
# Judge status: Wrong Answer
n=int(input())
k=int(input())
x=int(input())
y=int(input())
if k<n:
    print(k*x+(n-k)*y)
else:
    print(k*x)
# Judge status: Accepted
f=lambda:map(int,input().split())
input()
p,*A=f()
B=f()
monster = 0
for a,b in zip(A, B):
    t = min(b, p+a)
    p = a - max(0, t-p)
    monster += t
    
print(monster)
# Judge status: Accepted
A, B = map(int, input().split())
a, b = A, B
while b != 0:
  a, b = b, a % b
prod = 1
s = 1
p = 2
g = a
while a != 1:
  i = 0
  while a % p == 0:
    i += 1
    a //= p
    prod *= p
  if i != 0:
    s += 1
  p += 1
  if p > int(g**(1/2)) and prod != g:
    s += 1
    break
print(s)
# Judge status: Accepted
N, X, T = list(map(int, input().split()))
if N%X == 0:
  print((N//X)*T)
else:
  print((N//X)*T+T)
# Judge status: Wrong Answer
import sys
x,n = map(int,input().split())

if n == 0:
    print(x)
    sys.exit()

p,f = x-1,x+1
bans = set(map(int,input().split()))
while True:
    if p not in bans:
        print(p)
        break 
    p -= 1
    
    if f not in bans:
        print(f)
        break 
    f += 1
# Judge status: Accepted
N,H = [int(x) for x in input().split()]
from collections import deque
import math
c = []
d = []
for i in range(N):
  e,f = [int(x) for x in input().split()]
  c.append(e)
  d.append(f)
c.sort()
d.sort()
b = deque(d)
count = 0
while b:
  x = b.pop()
  if x > c[-1]:
    H -= x
    count += 1
    if H <= 0:
      print(count)
      exit()
count += math.ceil(H/c[-1])
print(count)
# Judge status: Accepted
s=""
n=int(input())
if n==0:print(0)
else:
 while n!=0:s=str(n%2)+s;n=-(n//2)
 print(s)
# Judge status: Accepted
def main():
    K = int(input())
    if K % 2 == 0 or K % 5 == 0:
        print(-1)
        return
    cnt = 1
    tmp = 7
    while tmp % K != 0:
        tmp = tmp * 10 + 7
        tmp %= K
        cnt += 1

    print(cnt)

main()
# Judge status: Accepted
N,K=map(int,input().split())
*A,=map(int,input().split())

print((N-2)//(K-1)+1)
# Judge status: Wrong Answer
N = int(input())
A = [int(i) for i in input().split()]
C = [0 for i in range(N)]
for value in A:
    C[value - 1] += 1
print(C)
ways_all = 0
for i in range(N):
    ways_all += (C[i] * (C[i] - 1)) // 2
print(ways_all)
for value in A:
    print(ways_all - C[value - 1] + 1)
# Judge status: Wrong Answer
def main():
    a, b, k = map(int, input().split())
    count = 0
    for i in range(1, max(a, b)):
        if a % i == 0 and b % i == 0:
            count += 1
        if count == k:
            print(i)
            return


if __name__ == "__main__":
    main()
# Judge status: Accepted
print("Yes" if input() in input()*2 else "No")
# Judge status: Wrong Answer
import sys
n,m,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))

d=min(y)-max(x)
if d<=0:
    print("War")
    sys.exit()
else:
    for i in range(d+1):
        Z=X+i
        if (Z<=X or Z>Y) or (max(x)>=Z or min(y)<Z):
            print("War")
            sys.exit()
print("No War")
# Judge status: Wrong Answer
N = int(input())

if N % 2 == 0:
  print(-1)
  exit()

n7 = 0
 
for i in range(6):
  n7 += 7*(10**(i))
  if n7 % N == 0:
    print(i+1)
    exit()

print(-1)
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
count = 0

for i in range(n):
  if b[i] <= a[i]:
    count = count + b[i]
  elif a[i] < b[i]:
    count = count + a[i]
    b[i] = b[i] - a[i]
    if a[i+1] <= b[i]:
      count = count + a[i+1]
      a[i+1] = 0
    elif b[i] < a[i+1]:
      count = count + b[i]
      a[i+1] = a[i+1] - b[i]
      
print(count)
# Judge status: Accepted
N, K = list(map(int, input().split()))
D = set(map(str, input().split()))

ans = N
while True:
  ans_set = set(str(ans))
  if ans_set & D:
    ans += 1
  else:
    break

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

for i in range(5):
    if list[i]==0:
        print(i+1)
# Judge status: Accepted
n,m,k=map(int,input().split())
n,m=min(n,m),max(n,m)
for i in range(n//2+n%2):
  num,dem=k-i*m,n-2*i
  if num%dem or not(0<=num//dem<=m):continue
  print("Yes");exit()
print("No")
# Judge status: Accepted
s=input()
n = len(s)

impossible = 0
num_s = 0

for v in s:
    if v=="S":
        num_s += 1
    else:
        if num_s==0:
            impossible += 2
        else:
            num_s -= 1

print(impossible)
# Judge status: Accepted
import math
a, b = (int(t) for t in input().split())
x = (a + b) / 2
print(math.ceil(x))
# Judge status: Accepted
N=int(input())
sum=0
ans="No"
for i in range(N):
    d=list(map(int,input().split()))
    if d[0]==d[1]:
        sum+=1
        if sum>2:
            ans="Yes"
            break
    else:
        sum=0
print(ans)
# Judge status: Wrong Answer
n = int(input())
flag = True
for _ in range(n):
    t, x, y = map(int, input().split())
    if t < x + y or (x + y + t) % 2:
        flag = False

print("Yes" if flag else "No")
# Judge status: Accepted
print(['No', 'Yes'][int(input()) >= 30])
# Judge status: Accepted
def solve():
    N = int(input())
    L0 = 2
    L1 = 1
    if N == 1:
        print(L1)
        exit()
    Li2 = L0
    Li1 = L1
    Li = Li1 + Li2
    for _ in range(N - 2):
        Li2 = Li1
        Li1 = Li
        Li = Li1 + Li2
    print(Li)

if __name__ == "__main__":
    solve()
# Judge status: Accepted
a1 = int(input())

calRList = []

calRList.append(a1)

i = 0
while True:
  if calRList[i] % 2 == 0:
    calRList.append(calRList[i]//2)
  else:
    calRList.append(3*calRList[i]+1)
  
  if calRList.count(calRList[i+1]) > 1:
    #index合わせ
    print((i+1)+1)
    break
  
  i+=1
# Judge status: Wrong Answer
a = list(map(int, input().split()))
b = a[0]
c = 0
while b > 0:
  b = b / a[1]
  c += 1
print(c)
# Judge status: Accepted
K, X = map(int, input().split())

if 500*K >= X:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
a, b = map(int, input().split())
print(-((-(a+b)) // 2))
# Judge status: Accepted
from fractions import gcd
n = int(input())
a = list(map(int,input().split()))
left = []
right = []

left.append(a[0])
for i in range(1,n-1):
    left.append(gcd(left[-1],a[i]))
a = a[::-1]
right.append(a[0])
for i in range(1,n-1):
    right.append(gcd(right[-1],a[i]))
ans = 1
for i in range(n-1):
    ans = max(ans,gcd(left[i],right[n-i-3]))
ans = max(ans,left[n-2],right[n-2])
print(ans)
# Judge status: Wrong Answer
s = ''.join(sorted(input()))
t = ''.join(sorted(input(), reverse=True))
if s < t:
  print('Yes')
else:
  print('NO')
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7
 
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
 
a = 1
for i in range(N):
    a = lcm(a, A[i])
 
ans = 0
for i in range(N):
    ans += a * pow(A[i], mod-2, mod)
 
print(ans % mod)
# Judge status: Wrong Answer
N,M=map(int,input().split())
print(((N*(N-1))/2)+((M*(M-1))/2))
# Judge status: Wrong Answer
N, T = map(int, input().split())
CT = [tuple(map(int, input().split())) for _ in range(N)]

ans = 101010
for c, t in CT:
    if t <= T:
        ans = min(ans, c)

print(ans if ans <= T else 'TLE')
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))

up=0
down=0
count = 0
x=a[0]
for i in range(n):
  if x==a[i]:
    continue
  elif x<a[i]:
    if down==0:
      up=1
    else:
      down=0
      up=0
      count+=1
  else:
    if up==0:
      down=1
    else:
      down=0
      up=0
      count+=1
  x=a[i]
print(count+1)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))

A=sorted(a)

m1=A[n//2 -1]
m2=A[n//2]
for i in range(n):
    if a[i]<=m1:
        print(m2)
    else:
        print(m1)
# Judge status: Accepted
n = int(input())
A = list(map(int, input().split()))

total_xor = 0
for a in A:
    total_xor ^= a

result = []
for a in A:
    result += [str(total_xor ^ a)]
print(' '.join(result))
# Judge status: Accepted
def resolve():
    D, N = list(map(int, input().split()))
    ls = [100 ** D * i for i in range(1, 100)]
    ls.append(100 ** D * 101)
    print(ls[N-1])
    return

resolve()
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
sumMonster = sum(A)

for i in range(N):
    if B[i] >= A[i]:
        A[i+1] -= B[i] - A[i]
        if A[i+1] < 0:
            A[i+1] = 0
        A[i] = 0
    else:
        A[i] -= B[i]

print(sumMonster-sum(A))
# Judge status: Wrong Answer
n = int(input())
l = list(map(int,input().split()))
l.sort()
sum = 0
print(l[0])
for i in range(n-1):
    sum += l[i]
if (sum <= l[n-1]):
    print("No")
else:
    print("Yes")
# Judge status: Accepted
X, Y=map(int,input().split())
T=4*X-Y
K=Y-2*X
if T>=0 and K>=0 and T%2==0 and K%2==0:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
from subprocess import*
p=run(('factor',input()),stdout=PIPE).stdout.split()[1:]
print(sum(int((8*p.count(i)+1)**.5/2-.5)for i in set(p)))
# Judge status: Wrong Answer
from bisect import bisect_right as br
mem=[]
for i in range(101):
  mem.append(i**5)
#print(mem)

x=int(input())
idx=br(mem,x)
a=idx-1
x-=mem[idx-1]
#print(x)
idx1=br(mem,abs(x))
#print(idx1)
if x>0:
    b=idx1-1
else:
    b=-(idx1-1)
print(a,b)
# Judge status: Accepted
a,b,c = map(int, input().split())
if a < c < b or b < c < a:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
import numpy as np
N, M = map(int, input().split())
shop = []
for _ in range(N):
    shop.append(list(map(int, input().split())))
i = 0
num = 0
ans = 0
shop = sorted(shop)
while num < M:
    ans += shop[i][0] * shop[i][1]
    num += shop[i][1]
    i += 1
ans -= (num - M) * shop[i -1][0]
print(ans)
# Judge status: Wrong Answer
x=int(input())
ans=2*(x//11)
x%=11
if x<7:ans+=1
else:ans+=2
print(ans)
# Judge status: Accepted
n,m = map(int,input().split())
if n*2 >= m:
    print(m//2)
else:
    print(n+(m-n*2)//4)
# Judge status: Accepted

X, Y = map(int, input().split())

count = 0

while X <= Y:
  count += 1
  X *= 2

print(count)
# Judge status: Wrong Answer
n, m = list(map(int, input().split()))

R, L = [], []
for i in range(m):
  r, l = list(map(int, input().split()))
  R.append(r)
  L.append(l)
  
print( min(R) - max(L) + 1)
# Judge status: Accepted
import itertools
n,k=map(int,input().split())
bl=[0]*(10**5+1)
for i in range(n):
  a,b=map(int,input().split())
  bl[a]+=b
ans=list(itertools.accumulate(bl))
for i in range(len(ans)+1):
  if k<=ans[i]:
    print(i)
    break
# Judge status: Accepted
N = input()
if '7' in N:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
N, M = map(int,input().split())
A = list(map(int, input().split()))
count = 0
ans = 0

for i in range(M):
    count += A[i]
    
if(N >= count):
    ans = N - count
    print(ans)
else:
    print('-1')
# Judge status: Accepted
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]

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

a.sort(reverse=True)

ali = 0
bob = 0

for i in range(n):
    if i % 2 == 0:
        ali += a[i]
    else:
        bob += a[i]
print(ali-bob)
# Judge status: Accepted
n = int(input())
s = input()
mod = 10 ** 9 + 7
cnt = [0] * 26  # それぞれの文字に対してfreqを数える
for i in s:
    cnt[ord(i) - 97] += 1
ans = 1
for i in cnt:
    ans *= i + 1
    ans %= mod
print(ans - 1)
# Judge status: Accepted
n = int(input())
w = input()
double_set = set()
double_set.add(w)
finish_str = w[-1]

for i in range(1, n):
    w = input()
    if w not in double_set and w[0] == finish_str:
        double_set.add(w) 
        finish_str = w[-1]
    else:
        print("No")
        break
else:
    print("Yes")
# Judge status: Accepted
n, *a = map(int, open(0).read().split())
money = 1000
stock = 0
for i in range(n-1):
    if a[i] < a[i+1]:
        stock = money // a[i]
        money += (a[i+1] - a[i]) * stock
print(money)
# Judge status: Accepted
A = list(map(int, input().split()))
print(max(A[0]*A[2], A[0]*A[3], A[1]*A[2], A[1]*A[3]))
# Judge status: Wrong Answer
n, d=map(int,input().split())

c = 0
for i in range(n):
    s = [int(i) for i in input().split()]
    if ((s[0]**2) + s[1]**2)**(1/2) >= d:
        c += 1

print(c)
# Judge status: Wrong Answer
N,K=map(int,input().split())
a=list(map(int,input().split()))
cycle=[0]
s_cyc=set()
s_cyc.add(0)
flag=0
id=0
for i in range(N):
    a[i]-=1
while N>0:
    if a[id] in s_cyc:
        node=cycle.index(a[id])
        break
    else:
        cycle.append(a[id])
        s_cyc.add(a[id])
        id=a[id]
    N-=1
if N==0:
    print(a[id]+1)
else:
    K-=node
    cycle=cycle[node::]
    q=K%len(cycle)
    print(cycle[q]+1)
# Judge status: Accepted
a,b,c=map(int,input().split())
k=int(input())
print(a+b+c+max(a,b,c)*(2**k-1))
# Judge status: Wrong Answer
s=input()
t=input()
n=len(s)
d={}
for i in range(n):
    ss=s[i]
    tt=t[i]
    if ss not in d:
        d[ss]=tt
    if ss in d and (ss,tt) not in d.items():
        print("No")
        exit()
    
print("Yes")
# Judge status: Accepted
Weather = ['Sunny','Cloudy','Rainy']
S = input()
for i,s in enumerate(Weather):
    if s == S:
        print(Weather[(i+1)%3])
# Judge status: Accepted
N = input()
N = N[::-1]+"0"
ans = 0
up = 0
for i,n in enumerate(N):
    d = int(n)+up
    if 5 < d or (d == 5 and i < len(N)-1 and int(N[i+1]) >= 5):
        ans += (10-d)
        up = 1
    else:
        ans += d
        up = 0
print(ans)
# Judge status: Accepted
N,A,B,C,D=map(int,input().split())
S=input()
s=list(S.split("#"))

answer="Yes"


if "##" in S[min(A,C):max(B,D)]:
    answer="No"
if C<D:
    pass
else:
    if "..." not in S[B-2:D+1]:
        answer="No"
    
print(answer)
# Judge status: Accepted
C = input()
alp = 'abcdefghijklmnopqrstuvwxyz'
alp_list = list(alp)
num = alp_list.index(C)
print(alp_list[num+1])
# Judge status: Accepted
import sys

input = sys.stdin.readline


def main():
    S = input().rstrip()

    ans = "2018" + S[4:]

    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import scipy as scp

# 入力の受け取り
n = int(input())

n = n-1

ans = (1+n)*n//2

print(ans)
# print("{:.10f}".format(ans))
# Judge status: Wrong Answer
x, y = map(int, input().split())
al = []
a = x
al.append(a)
for i in range(int(x) - 1):
  a *= 2
  if a > y:
    break
  al.append(a)
print(len(al))