Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

N = int(input())

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

ones = [0] * 60
m = 10 ** 9 + 7

for Ai in A:
    for digit in range(60):
        ones[digit] += ((Ai >> digit) & 1)

res = 0
for i, num in enumerate(ones):
    res = (res + (1 << i) * num * (N - num)) % m

print(res)


### FIXED CODE ###

N = int(input())

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

num = [[0, 0] for _ in range(60)]

for Ai in A:
    for digit in range(60):
        if (Ai >> digit) & 1:
            num[digit][1] += 1
        else:
            num[digit][0] += 1

res = 0
for i, p in enumerate(num):
    res += (1 << i) * p[0] * p[1]

m = 10 ** 9 + 7
print(res % m)
### BUGGY CODE ###

a,b,k = map(int,input().split())
for i in range(a,b+1):
    if (i<a+k) or (b-k<i):
        print(i)


### FIXED CODE ###

a,b,k = map(int,input().split())
x=[]
for i in range(k):
    if a<=a+i<=b:
        x.append(a+i)
        x.append(b-i)
x = sorted(list(set(x)))
for i in x:
    print(i)
### BUGGY CODE ###

S = input()
N = len(S)
MOD = 10 ** 9 + 7

dp = [[0] * 13 for _ in range(N + 1)]
dp[0][0] = 1
for i in range(N):
    c = int(S[i]) if S[i] != "?" else -1
    for j in range(10):
        if c == -1 or c == j:
            for ki in range(13):
                dp[i+1][(ki * 10 + j) % 13] += dp[i][ki]
    for j in range(13):
        dp[i+1][j] %= MOD
ans = dp[N][5]
print(ans)

### FIXED CODE ###

S = input()
N = len(S)
MOD = 10 ** 9 + 7

dp = [[0] * 13 for _ in range(N + 1)]
dp[0][0] = 1
for i in range(N):
    c = int(S[i]) if S[i] != "?" else -1
    for j in range(10):
        if c == -1 or c == j:
            for ki in range(13):
                dp[i+1][(ki * 10 + j) % 13] += dp[i][ki]
    for j in range(13):
        dp[i+1][j] %= MOD
ans = dp[N][5]
print(ans)
### BUGGY CODE ###

# https://atcoder.jp/contests/abc169/submissions/16260280
# F - Knapsack for All Subsets
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 998244353


def resolve():
    """ 愚直解 """
    dp = [[0] * (s + 1) for _ in range(n + 1)]
    dp[0][0] = 1
    for i in range(1, n + 1):
        a = A[i - 1]
        for prev in range(i):
            for j in range(s + 1):
                dp[i][j] += dp[prev][j]
                if a + j > s:
                    continue
                dp[i][a + j] += dp[prev][j]
                dp[i][a + j] %= mod
    print(dp)
    res = 0
    for i in range(1, n + 1):
        res += dp[i][-1]
        res %= mod
    print(res)


def resolve2():
    """ DP + 累積和 """
    dp = [[0] * (s + 1) for _ in range(n + 1)]
    dp[0][0] = 1
    cnt_num = [0] * (s + 1)
    cnt_num[0] = 1
    res = 0
    for i in range(1, n + 1):
        a = A[i - 1]
        for j in range(s + 1):
            dp[i][j] += cnt_num[j]
            dp[i][j] %= mod
            if a + j > s:
                continue
            dp[i][a + j] += cnt_num[j]
            dp[i][a + j] %= mod
        for k in range(s + 1):
            cnt_num[k] = cnt_num[k] + dp[i][k]
            cnt_num[k] %= mod
        res += dp[i][-1]
        res %= mod
    print(res)


if __name__ == '__main__':
    n, s = map(int, input().split())
    A = list(map(int, input().split()))
    resolve2()


### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 998244353


def resolve():
    """ 愚直解 """
    dp = [[0] * (s + 1) for _ in range(n + 1)]
    dp[0][0] = 1
    for i in range(1, n + 1):
        a = A[i - 1]
        for prev in range(i):
            for j in range(s + 1):
                dp[i][j] += dp[prev][j]
                if a + j > s:
                    continue
                dp[i][a + j] += dp[prev][j]
                dp[i][a + j] %= mod
    print(dp)
    res = 0
    for i in range(1, n + 1):
        res += dp[i][-1]
        res %= mod
    print(res)


def resolve2():
    """ DP + 累積和 """
    dp = [[0] * (s + 1) for _ in range(n + 1)]
    dp[0][0] = 1
    cnt_num = [0] * (s + 1)
    cnt_num[0] = 1
    res = 0
    for i in range(1, n + 1):
        a = A[i - 1]
        for j in range(s + 1):
            dp[i][j] += cnt_num[j]
            dp[i][j] %= mod
            if a + j > s:
                continue
            dp[i][a + j] += cnt_num[j]
            dp[i][a + j] %= mod
        for k in range(s + 1):
            cnt_num[k] = cnt_num[k] + dp[i][k]
            cnt_num[k] %= mod
        res += dp[i][-1]
        res %= mod
    print(res)


if __name__ == '__main__':
    n, s = map(int, input().split())
    A = list(map(int, input().split()))
    resolve2()
### BUGGY CODE ###

#!/usr/bin/env python3
import io
import os


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

    w, v = [0] * n, [0] * n
    for i in range(n):
        w[i], v[i] = map(int, input().split())

    dp = [0] * (m + 1)
    for i in range(w[0], m + 1):
        dp[i] = v[0]
    for i in range(n - 1):
        dp = [dp[j] if j < w[i + 1] else max(v[i + 1] + dp[j - w[i + 1]], dp[j]) for j in range(m + 1)]

    print(dp[-1])


input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
main()


### FIXED CODE ###

#!/usr/bin/env python3
import os
import sys
from atexit import register
from io import StringIO

sys.stdin = StringIO(os.read(0, os.fstat(0).st_size).decode())
sys.stdout = StringIO()
register(lambda: os.write(1, sys.stdout.getvalue().encode()))

input = lambda: sys.stdin.readline().rstrip('\r\n')

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

w, v = [0] * n, [0] * n
for i in range(n):
    w[i], v[i] = map(int, input().split())

dp = [[0] * (m + 1) for _ in range(n)]
for j in range(w[0], m + 1):
    dp[0][j] = v[0]

for i in range(1, n):
    for j in range(m + 1):
        if j < w[i]:
            dp[i][j] = dp[i - 1][j]
        else:
            dp[i][j] = max(v[i] + dp[i - 1][j - w[i]], dp[i - 1][j])

print(dp[-1][-1])
### BUGGY CODE ###

import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))
ZIP = lambda: zip(*(MAP() for _ in range(n)))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N, K = MAP()
    A = LIST()

    sub = reduce(mul, A[:K])
    for i in range(N-K):
        temp = reduce(mul, A[i+1:i+K+1])
        print("Yes" if sub < temp else "No")
        sub = temp


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))
ZIP = lambda: zip(*(MAP() for _ in range(n)))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N, K = MAP()
    A = LIST()

    for i in range(N-K):
        print("Yes" if A[i] < A[i+K] else "No")


if __name__ == '__main__':
    main()
### BUGGY CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7


def extgcd(a,b):
    a0,b0=a,b
    x0,y0=1,0
    x1,y1=0,1

    while b0!=0:
        q = a0 // b0
        r = a0 % b0

        a0,b0=b0,r
        x0,x1=x1,x0-q*x1
        y0,y1=y1,y0-q*y1

    return a0,x0,y0

def mo(x,mod):
    return (mod+x%mod)%mod

def inv(a,mod):
    g,x,y=extgcd(a,mod)
    ans=mo(x,mod)
    return ans

def combi_mod(n,k):
    invlist = [1]
    for i in range(1, k + 1):
        temp = inv(i, mod)
        invlist.append(temp)
    k1 = 1
    k3 = 1

    for i in range(n, 0, -1):

        if i > n - k:
            k1 *= i
        if i < k + 1:
            k3 *= invlist[i]
    ans = k1 * k3
    ans = ans % mod
    return ans

A.sort()

ans=0

for i in range(N):
    if i <= N - K :
        ans -= A[i] * combi_mod(N - i - 1, K - 1)
    if K - 1 <= i:
        ans += A[i] * combi_mod(i, K - 1)
ans=ans%mod

print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7

fac=[]
finv=[]
inv=[]
def combi_init():
    fac.append(1)
    fac.append(1)
    finv.append(1)
    finv.append(1)
    inv.append(1)
    inv.append(1)

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

def combi_mod(n,k):

    ret=fac[n]*finv[n-k]*finv[k]%mod
    return ret

A.sort()

ans=0
combi_init()
for i in range(N-1,K-2,-1):
    ans+=(A[i]-A[(N-1)-i])*combi_mod(i,K-1)


ans%=mod

print(ans)
### BUGGY CODE ###

def main():
    N = int(input())
    a = input().split(" ")
    L = []
    for i in range(N):
        L.append("")
    for i in range(N):
        L[int(a[i]) - 1] = str(i + 1)
    ans = ""
    for l in L:
        ans = ans + l + " "
    print(ans[:-1])


if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    N = int(input())
    A = map(int, input().split(" "))
    list = [""] * (N + 1)
    for i, a in enumerate(A, 1):
        list[a] = str(i)
    print(" ".join(list[1:]))


if __name__ == '__main__':
    main()
### BUGGY CODE ###

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

ml = [0 for _ in range(n)]

while len(set(dl)) != 1 :
    m = max(dl)
    for i in range(n) :
        if dl[i] == m :
            if dl[i-1] >= dl[(i+1)%n] :
                lain = max(dl[i-1]-dl[i-2], dl[i]-dl[(i+1)%n])
                dl[i-1] -= lain
                dl[i] -= lain
                ml[i] += 2*lain
            else :
                lain = max(dl[i]-dl[i-1], dl[(i+1)%n]-dl[(i+2)%n])
                dl[i] -= lain
                dl[(i+1)%n] -= lain
                ml[(i+1)%n] += 2*lain
else :
    for i in range(n) :
        ml[i] += dl[-1]

for i in range(n) :
    print(ml[i],end=" ")

### FIXED CODE ###

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

# m0 + m1 + m2 + m3 + m4 = d0 + d1 + d2 + d3 + d5
# d0 = (m0 + m1)//2
# d1 = (m1 + m2)//2
# d2 = (m2 + m3)//2
# d3 = (m3 + m4)//2
# d4 = (m4 + m0)//2
# m0 =  d0 - d1 + d2 - d3 + d4
# m1 =  d0 + d1 - d2 + d3 - d4
# m2 = -d0 + d1 + d2 - d3 + d4
# m3 =  d0 - d1 + d2 + d3 - d4
# m4 = -d0 + d1 - d2 + d3 + d4   
s = sum(a)
p = [0 for _ in range(n)]
q = [0 for _ in range(n+1)]
for i in range(n) :
    if i>1 :
        p[i] = p[i-2] + a[i-2]
    q[n-i-2] = q[n-i] + a[n-i-1]

print(*[s-2*p[i]-2*q[i] for i in range(n)])
### BUGGY CODE ###

from collections import defaultdict, deque


def solve():
    N, K = map(int, input().split())
    d = defaultdict(list)
    MOD = 10**9+7

    for _ in range(N-1):
        a, b = map(int, input().split())
        d[a].append(b)
        d[b].append(a)

    ans = K
    used = [0]*(N+1)
    used[1] = True
    q = deque([1])

    while q:
        a = q.popleft()
        s = 1 if a==1 else 2
        for b in d[a]:
            if used[b]:continue
            used[b] = True
            ans *= (K-s)
            s += 1
            q.append(b)

        ans %= MOD
    print(ans)

solve()

### FIXED CODE ###

from collections import defaultdict
v = defaultdict(list)
mod = 10**9+7

N, K = map(int, input().split())
for _ in range(N-1):
    a, b = map(int, input().split())
    v[a].append(b)
    v[b].append(a)

visited = [False]*(N+1)
ans = 1

q = [(1, 0, 0)]
while q:
    pos, parent, score = q.pop()
    visited[pos] = True
    ans *= (K-score)
    ans %= mod 
   
    a = 1 if pos==1 else 2
    b = 0

    for i in v[pos]:
        if visited[i]:continue
        q.append((i, pos, a+b))
        b += 1

print(ans)
### BUGGY CODE ###

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
    
cnt = 0
s = []
tmp = []
n = int(input())
for i in range(n):
    string = input()
    string = ''.join(sorted(string))
    s.append(string)

for i, e in enumerate(s):
    """
    要素が何個あるか検査　AND　tmpにないやつ
    ・１：なにもしない
    ・2以上：個数調べてCNT更新。その要素をtmpに記録する
    """
    count = s.count(e)
    if count > 1 and not e in tmp:
        cnt += cmb(count, 2)
        tmp.append(e)
print(cnt)


### FIXED CODE ###

import collections

cnt = 0
s = []
tmp = []
n = int(input())
for i in range(n):
    string = input()
    string = ''.join(sorted(string))
    s.append(string)

# for i, e in enumerate(s):
#     count = s.count(e)
#     if count > 1 and not e in tmp:
#         cnt += count*(count-1)//2
#         tmp.append(e)
cc = collections.Counter(s)

for cv in cc.values():
    if cv > 1:
        cnt += cv*(cv-1)//2

print(cnt)
### BUGGY CODE ###

from collections import defaultdict
def main():
  n,k=map(int,input().split())
  xy=[list(map(int,input().split())) for _ in range(n)]
  xwl=dict((c[0],i) for i,c in enumerate(xy))
  ywl=dict((c[1],i) for i,c in enumerate(xy))
  x=list(xwl.keys())
  y=list(ywl.keys())
  x.sort()
  y.sort()
  
  xdict=dict()
  ydict=dict()
  xdict[x[0]]=[1<<xwl[x[0]],0]
  ydict[y[0]]=[1<<ywl[y[0]],0]
  size=lambda x:sum(x>>i&1 for i in range(n))
  minus=lambda x,y:(x|y)^y
  for i in range(1,n):
    xdict[x[i]]=[xdict[x[i-1]][0]|(1<<xwl[x[i]]), xdict[x[i-1]][1]|(1<<xwl[x[i-1]])]
    ydict[y[i]]=[ydict[y[i-1]][0]|(1<<ywl[y[i]]), ydict[y[i-1]][1]|(1<<ywl[y[i-1]])]
  ans=float('inf')
  diter=[(i,j) for i in range(n) for j in range(n) if i<j]
  
  for s,t in diter: 
    for u,v in diter:
      if size(minus(xdict[x[t]][0],xdict[x[s]][1])&\
                  minus(ydict[y[v]][0],ydict[y[u]][1]))>=k:
        ans=min(ans,(x[t]-x[s])*(y[v]-y[u]))
  print(ans)

if __name__=='__main__':
  main()


### FIXED CODE ###

from collections import defaultdict
def main():
  n,k=map(int,input().split())
  xy=[list(map(int,input().split())) for _ in range(n)]
  x=[p[0] for p in xy]
  y=[p[1] for p in xy]
  x.sort()
  y.sort()
  
  s1=[[0]*n for _ in range(n)]
  s2=[[0]*n for _ in range(n)]
  s3=[[0]*n for _ in range(n)]
  s4=[[0]*n for _ in range(n)]
  for i in range(n):
    for j in range(n):
        for p in xy:
            if p[0]<=x[i] and p[1]<=y[j]:
              s1[i][j]+=1
              s2[i][j]+=(p[0]<x[i])
              s3[i][j]+=(p[1]<y[j])
              s4[i][j]+=(p[0]<x[i])*(p[1]<y[j])
  ans=float('inf')
  for s in range(n):
    for t in range(s+1,n):
      for u in range(n):
        for v in range(u+1,n):
          if s1[t][v]-s3[t][u]-s2[s][v]+s4[s][u]>=k:
            ans=min(ans,(x[t]-x[s])*(y[v]-y[u]))
  print(ans)

if __name__=='__main__':
  main()
### BUGGY CODE ###

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

for _ in range(min(k,1000)):
    s=[0 for _ in range(n)]
    e=[0 for _ in range(n)]
    for i in range(n):
        d=a[i]
        s[max(0,i-d)]+=1
        e[min(n-1,i+d)]+=1
    a[0]=s[0]
    for i in range(1,n):
        s[i]=s[i-1]+s[i]
        e[i]=e[i-1]+e[i]
        a[i]=s[i]-e[i-1]

print(*a)

### FIXED CODE ###

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

for _ in range(min(k,100)):
    s=[0 for _ in range(n)]
    e=[0 for _ in range(n)]
    for i in range(n):
        d=a[i]
        s[max(0,i-d)]+=1
        e[min(n-1,i+d)]+=1
    a[0]=s[0]
    for i in range(1,n):
        s[i]=s[i-1]+s[i]
        e[i]=e[i-1]+e[i]
        a[i]=s[i]-e[i-1]

print(*a)
### BUGGY CODE ###

#!/usr/bin/env python3
import sys

def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 0
    for i in range(N):
        for j in range(i,N):
            if A[j] == -A[i] + j-i:
                ans += 1
    print(ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
from bisect import bisect_left,bisect_right

def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = [i+A[i] for i in range(N)] 
    B.sort()
    C = [i-A[i] for i in range(N)] 
    C.sort()
    ans = 0
    for i in range(N):
        ans += bisect_right(C,B[i]) - bisect_left(C,B[i])
    print(ans)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

K, S = map(int, input().split())

counter = 0
for h in range(K + 1):
    for i in range(K + 1):
        for j in range(K + 1):
            if h + i + j == S:
                counter += 1
print(counter)

### FIXED CODE ###

K, S = map(int, input().split())
        
counter = 0
for h in range(K + 1):
    for i in range(K + 1):
        j = S - h - i
        if j <= K and j >= 0:
            counter += 1
print(counter)
### BUGGY CODE ###

n,q = map(int, input().split())
s = list(input())
lr_list = [list(map(int,input().split())) for _ in range(q)]

for l,r in lr_list:
    tmp_str = ''.join(s[l-1:r])
    print(tmp_str.count('AC'))

### FIXED CODE ###

n,q = map(int, input().split())
s = list(input())
lr_list = [list(map(int,input().split())) for _ in range(q)]
tmp_list = [0]*(n+1)

for i in range(1,n):
    if s[i-1]=='A' and s[i]=='C':
        tmp_list[i] = tmp_list[i-1]+1
    else:
        tmp_list[i] = tmp_list[i-1]

for l,r in lr_list:
    print(tmp_list[r-1]-tmp_list[l-1])
### BUGGY CODE ###

import fractions
import copy

n1 = int(input())
nl1 = [int(i1) for i1 in input().split()]

r1 = 0
for  i2 in range(n1):
    nl2 = copy.copy(nl1)
    if i2 == 0:
        nl2[i2] = nl1[1]
    else:
        nl2[i2] = nl1[i2 - 1]
    r2 = nl2[0]
    for i3 in range(n1 - 1):
        r2 = fractions.gcd(r2 ,nl2[i3 + 1])

    r1 = max(r1,r2)

print(str(r1))

### FIXED CODE ###

import fractions
import sys

n1 = int(input())
nl1 = [int(i1) for i1 in input().split()]

if n1 == 2:
    print(max(nl1))
    sys.exit()

r1 = 0

nl1.sort()

if n1 >= 3:
    n2 = fractions.gcd(nl1[0], nl1[1]) 
    n2 = max(n2, fractions.gcd(nl1[1], nl1[2]))
    n2 = max(n2, fractions.gcd(nl1[0], nl1[2]))

c1 = 0
for i2 in range(n1):
    if nl1[i2] % n2 != 0:
        c1 += 1
    if c1 >= 2:
        break
    if i2 == (n1 - 1):
        r1 = n2

i3 = n2

while r1 == 0:
    c1 = 0
    for i4 in range(n1):
        if nl1[i4] % i3 != 0:
            c1 += 1
        if c1 >= 2:
            break
        if i4 == (n1 - 1):
            r1 = i3
    i3 -= 1

print(str(r1))
### BUGGY CODE ###

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

def sumcmb(T):
    count=0
    m=T
    while m>=0:
        count+=cmb(T,m)
        T-=1
        m-=2
    return(count)


N,M=map(int,input().split())
A=[int(input()) for i in range(M)]
mod=10**9+7
for i in range(M-1):
    if A[i]+1==A[i+1]:
        print(0)
        exit()

if 1 not in A:
    A.insert(0,-1)
if N not in A:
    A.append(N+1)


count=1
for i in range(len(A)-1):
    T=max(A[i+1]-1 - (A[i]+1),1)
    #print(sumcmb(T))
    count*=sumcmb(T)
    count%=mod
print(count)


### FIXED CODE ###

N,M=map(int,input().split())
mod=10**9+7
A=set([int(input()) for i in range(M)])

data=[0 for i in range(N)]
if 1 not in A:
    data[0]=1
if N>=2:
    if 2 not in A:
        data[1]=1+data[0]


for i in range(2,N):
    if i+1 not in A:
        data[i]=data[i-1]+data[i-2]
        data[i]%=mod

#print(data)

print(data[-1])
### BUGGY CODE ###

from sys import stdin
import numpy as np
def main():
    #入力
    readline=stdin.readline
    n,k=map(int,readline().split())
    a=np.array(list(map(int,readline().split())),dtype=np.int64)

    cnt=0
    while cnt<k:
        s=[0]*n
        for i in range(n):
            x_min=i-a[i]
            x_max=i+a[i]+1
            s[max(0,x_min)]+=1
            if n-1<x_max:
                pass
            else:
                s[x_max]-=1
        a=np.cumsum(s)
        cnt+=1
        
        if a[a==n].size==n:
            break

    print(*a)

if __name__=="__main__":
    main()

### FIXED CODE ###

from sys import stdin
from itertools import accumulate
def main():
    #入力
    readline=stdin.readline
    n,k=map(int,readline().split())
    a=list(map(int,readline().split()))

    cnt=0
    while cnt<k:
        s=[0]*n
        for i in range(n):
            x_min=i-a[i]
            x_max=i+a[i]+1
            s[max(0,x_min)]+=1
            if n-1<x_max:
                pass
            else:
                s[x_max]-=1
        a=list(accumulate(s))
        cnt+=1
        
        flag=True
        for i in range(n):
            if a[i]!=n:
                flag=False
                break
        if flag: break

    print(*a)

if __name__=="__main__":
    main()
### BUGGY CODE ###

import itertools as it

N =  int(input())
n =list(map(str,range(10)))
ans = 0
for i in it.combinations_with_replacement(n,16):
  a = int("".join(i))
  if a <= N:
    b = sum(map(int,i))
    ans = max(ans,b)
print(ans)

### FIXED CODE ###

import itertools as it

N =  int(input())
n =list(map(str,range(10)))
ans = 0
for i in it.combinations_with_replacement(n,16):
  a = int("".join(i))
  if a <= N:
    b = sum(map(int,i))
    ans = max(ans,b)
print(ans)
### BUGGY CODE ###

from collections import deque
import sys
sys.setrecursionlimit(10**7)

N,M = map(int,input().split())
Graph =[[] for i in range(N)]
for i in range(M):
    L,R,D = map(int,input().split())
    Graph[L-1].append((R-1,D))
    Graph[R-1].append((L-1 ,-D))
visit=[False]*N
for i in range(N):
    if visit[i]==False:
        visit[i]=0
        A = deque()
        A.append(i)
        while A:
            x = A.pop()
            for y,d in Graph[x]:
                if (visit[y] != False) and (visit[y]!=d+visit[x]):
                    print('No')
                    sys.exit()
                elif (visit[y] == False):
                    A.append(y)
                    visit[y]=d+visit[x] 
    
print('Yes')

### FIXED CODE ###

from collections import deque
import sys
sys.setrecursionlimit(10**7)

N,M = map(int,input().split())
Graph =[[] for i in range(N)]
for i in range(M):
    L,R,D = map(int,input().split())
    Graph[L-1].append((R-1,D))
    Graph[R-1].append((L-1 ,-D))
visit=[False]*N
dist=[0]*N
for i in range(N):
    if visit[i]==False:
        visit[i]=True
        A = deque()
        A.append(i)
        while A:
            x = A.pop()
            for y,d in Graph[x]:
                if (visit[y] == True) and (dist[y]!=d+dist[x]):
                    print('No')
                    sys.exit()
                elif (visit[y] == False):
                    visit[y]=True
                    A.append(y)
                    dist[y]=d+dist[x] 
    
print('Yes')
### BUGGY CODE ###

n=int(input())
import fractions 
from functools import reduce
arr = list(map(int,input().split()))


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

def lcm(numbers):
    return reduce(lcm_base, numbers, 1)
    
a = lcm(arr)

ans = 0

for i in arr:
    ans+= a//i
    if ans >1000000007:
        ans % 1000000007
print(ans %(1000000000+7))

### FIXED CODE ###

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)
### BUGGY CODE ###

import math

if __name__ == '__main__':
    n = int(input())
    N = math.ceil(math.sqrt(n))
    k = n+1
    for i in range(n):
        if n % N == 0:
            print(int(n/N - 1) + N - 1)
            break
        else:
            N = N + 1

### FIXED CODE ###

n = int(input())
s = int(n ** 0.5)
list = []
for i in range(1, s + 1):
    if n % i == 0:
        list.append(int(i + n / i - 2))
print(min(list))