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

class PQueue:
    def __init__(self):
        self.keys = []
        
    def maxHeapify(self, i):
        l = i * 2 + 1
        r = i * 2 + 2
        if l < len(self.keys) and self.keys[l] > self.keys[i]:
            largest = l
        else:
            largest = i
        if r < len(self.keys) and self.keys[r] > self.keys[largest]:
            largest = r
        if largest != i:
            self.keys[i], self.keys[largest] = self.keys[largest], self.keys[i]
            self.maxHeapify(largest)

    def insert(self, key):
        i = len(self.keys)
        self.keys.append(key)
        parent = (i - 1) // 2
        while i > 0 and self.keys[parent] < self.keys[i]:
            self.keys[i], self.keys[parent] = self.keys[parent], self.keys[i]
            i = parent
            parent = (parent - 1) // 2

    def heapExtraMax(self):
        max_key = self.keys[0]
        if len(self.keys) > 1:
            self.keys[0] = self.keys.pop()
        else:
            del self.keys[0]
        self.maxHeapify(0)
        return max_key


S = PQueue()

import sys

for x in sys.stdin.readlines():
    if x[0] == 'i':
        k = int(x[7:])
        S.insert(k)
    elif x[1] == 'x':
        m_k = S.heapExtraMax()
        print(m_k)
    else:
        pass

### FIXED CODE ###

def setHeapDown_max(heap, pos):
    targetkey = heap[pos]
    while pos > 0:
        parentpos = (pos - 1) >> 1
        parent = heap[parentpos]
        if parent < targetkey:
            heap[pos] = parent
            pos = parentpos
            continue
        break
    heap[pos] = targetkey

def setHeapUp_max(heap, pos):
    endpos = len(heap)
    targetkey = heap[pos]
    childpos = 2*pos + 1
    while childpos < endpos:
        rightpos = childpos + 1
        if rightpos < endpos and not heap[rightpos] < heap[childpos]:
            childpos = rightpos
        heap[pos] = heap[childpos]
        pos = childpos
        childpos = 2*pos + 1
    heap[pos] = targetkey
    setHeapDown_max(heap, pos)

def heapPush_max(heap, key):
    heap.append(key)
    setHeapDown_max(heap, len(heap) - 1)

def heapPop_max(heap):
    lastkey = heap.pop()
    if heap:
        returnkey = heap[0]
        heap[0] = lastkey
        setHeapUp_max(heap, 0)
        return returnkey
    return lastkey


import sys

S = []

ans = []

for x in sys.stdin.readlines():
    if x[0] == 'i':
        k = int(x[7:])
        heapPush_max(S, k)
    elif x[1] == 'x':
        ans.append(heapPop_max(S))
    else:
        pass

print(*ans, sep = '\n')
### BUGGY CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from math import factorial 
P = int(1e9)+7
def c(n, m, P):
       ch = 1
       for i in range(m):
           ch *= (n-i)
           ch %= P
       b = factorial(m) 
       b = pow(b, P-2, P)
       return ch*b%P
def main():
    x, y = map(int, readline().split())
    if ((2*y-x)%3) or ((2*x-y)%3):
        print(0)
        return
    a = (2*y-x)//3
    b = (2*x-y)//3
    if a < 0:
        print(0)
        return
    if b < 0:
        print(0)
        return
    print(c(a+b, a, P)) 
if __name__ == '__main__':
    main()


### FIXED CODE ###

#python3
from math import factorial
from math import floor
MOD = int(1e9+7)

def comb(n, m, mod):
    comb_a = 1
    for i in range(m): 
        comb_a *= (n-i)
        comb_a %= mod
    comb_tmp = factorial(m) 
    comb_b = pow(comb_tmp, mod-2, mod)
    return (comb_a * comb_b)%mod
def main():
    x, y = map(int, input().split())
    k = (2*x-y)/3
    l = (2*y-x)/3

    if floor(k) - k != 0:
        print(0)
        return
    if floor(l) - l != 0:
        print(0)
        return 
    if k<0:
        print(0)
        return
    if l<0:
        print(0)
        return
    k = int(k)
    l = int(l)
    print(comb(k+l, k, MOD)%MOD) 

main()
### BUGGY CODE ###

# cook your dish here
import math
n,a,b,k= map(int,input().split())



w = [1]
for i in range(0,n):
    w.append(w[-1]*(n-i)//(i+1))
#コンビネーションw[i] = nCi


c = 0
if k//a >= n:
    x = n
else:
    x = k //a

if k == 0:
    c = 1
else:
    for h in range(0,x+1):
        i = (k-a*h)/b

        if i == int(i) and n >= i:
            c = w[h]*w[int(i)]%998244353+c

print(c%998244353)

### FIXED CODE ###

mod = 998244353

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

fact = [1]
fact_inv = [1]
for i in range(n+4):
    new_fact = fact[-1]*(i+1)%mod
    fact.append(new_fact)
    fact_inv.append(pow(new_fact,mod-2,mod))


def mod_comb_k(n,k,mod):
    return fact[n] * fact_inv[k] % mod * fact_inv[n-k] %mod


res = 0

for i in range(n+1):
    if k - a*i < 0:
        continue
    
    if (k-a*i)%b != 0:
        continue

    j = (k-a*i)//b

    if j > n:
        continue

    res = (res + mod_comb_k(n,j,mod)*mod_comb_k(n,i,mod)%mod)%mod

print(res%mod)
### BUGGY CODE ###

K,S=map(int,input().split())
count=0
for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if x+y+z == S:
                count+=1
print(count)

### FIXED CODE ###

K,S=map(int,input().split())
count=0
for x in range(K+1):
    for y in range(K+1):
        z=S-x-y
        if z>=0 and z<=K:
            count+=1
print(count)
### BUGGY CODE ###

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

output='Yes'
for i in range(N-1):
  if h[i]-h[i+1]>0:
    if h[i]-min(h[i+1:])>1:
      output='No'
      
print(output)

### FIXED CODE ###

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

index=N-1
output='Yes'
while index>0:
  if h[index-1]-h[index]>1:
    output='No'
    break
  elif h[index-1]-h[index]==1:
    h[index-1]-=1
  else:
    pass
  index-=1
  
print(output)
### BUGGY CODE ###

import itertools
import math
import fractions
import functools
k = int(input())
h_list = []



def gcd(numbers):
    return functools.reduce(fractions.gcd, numbers)

for i in range(1,k+1):
    for j in range(1,k+1):
        for k in range(1,k+1):
            h_list.append([i,j,k])

sum = 0
for i in range(len(h_list)):
    sum += gcd(h_list[i])

print(sum)

### FIXED CODE ###

import itertools
import math
import fractions
import functools

K = int(input())
 
res = 0
for i in range(1, K+1):
  for j in range(1, K+1):
    gcd1 = math.gcd(i, j)
    for k in range(1, K+1):
      if gcd1 == 1:
        res += 1
      else:
        res += math.gcd(gcd1, k)
print(res)
### BUGGY CODE ###

n = int(input())
Ai = list(map(int, input().split()))
sum_ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        sum_ans += Ai[i] * Ai[j]
        sum_ans = sum_ans % (10**9 + 7)

print(sum_ans)

### FIXED CODE ###

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

sum_ans = sum(Ai)
ans = 0
mod = 1000000007

for i in range(n-1):
    sum_ans -= Ai[i]
    ans += sum_ans * Ai[i]
    ans %= mod

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

import sys

def main():
    input = sys.stdin.readline
    MOD = 10**9 + 7
    N, M = map(int, input().split())
    S = [0] + list(map(int, input().split()))
    T = [0] + list(map(int, input().split()))

    dp = [[0] * (M+1) for _ in range(N+1)]
    for i in range(1, N+1):
        for j in range(1, M+1):
            dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1]
            if S[i] == T[j]:
                dp[i][j] += dp[i-1][j-1] + 1
            dp[i][j] %= MOD

    return (dp[N][M] + 1) % MOD


if __name__ == '__main__':
    print(main())


### FIXED CODE ###

import sys

def main():
    input = sys.stdin.readline
    MOD = 10**9 + 7
    N, M = map(int, input().split())
    S = [0] + list(map(int, input().split()))
    T = [0] + list(map(int, input().split()))

    dp = [[0] * (M+1) for _ in range(N+1)]
    for i in range(1, N+1):
        for j in range(1, M+1):
            if S[i] == T[j]:
                dp[i][j] = dp[i-1][j] + dp[i][j-1] + 1
            else:
                dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1]
            dp[i][j] %= MOD

    return (dp[N][M] + 1) % MOD


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

n, k = map(int, input().split())
h = tuple(map(int, input().split()))
d = dict()
for i in range(n):
    d[i] = h[i]

inf = 10**9
dp = [inf]*n
dp[0] = 0
for i in range(n):
    for j in range(1, k+1):
        step = i+j
        if step < n:
            dp[step] = min(dp[step], dp[i]+abs(d[step]-d[i]))
print(dp[-1])


### FIXED CODE ###

def main():
    n, k = map(int, input().split())
    stones = tuple(map(int, input().split()))
    inf = 10**9
    dp = [inf]*n
    dp[0] = 0
    for i in range(n):
        for t in range(1, k+1):
            step = i+t
            if step < n:
                v = dp[i]+abs(stones[i]-stones[step])
                if v < dp[step]:
                    dp[step] = v
    print(dp[-1])


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

n = int(input())
li = list(map(int,input().split()))
a = 1
count = 0
for i in range(n):
    a = a*li[i]
while a % 2 == 0:
    a = a // 2
    count += 1
print(count)

### FIXED CODE ###

n = int(input())
li = list(map(int,input().split()))
a = 1
count = 0
for i in range(n):
    a = a*li[i]
while a % 2 == 0:
    a = a // 2
    count += 1
print(count)
### BUGGY CODE ###

import heapq

n,m=[int(i) for i in input().split()]
List=[int(i) for i in input().split()]

for i in range(m):
    a,b=[int(i) for i in input().split()]
    for j in range(a):
        List.append(b)

List.sort()
print(sum(List[-n:]))

### FIXED CODE ###

N,M = [int(x) for x in input().split()]

A = [int(x) for x in input().split()]
A.sort()
max = 0
BC = []
for i in range(M):
    b,c = [int(x) for x in input().split()]
    max += b
    BC.append([c,b])

BC.sort(reverse = True)
str =[]
for c,b in BC:
    str+=[c]*b
    # print(str)
    if(len(str) > N):
        break

now = 0
for i in range(len(A)):
    if(now >= max or str[now] < A[i]):
        break
    if(A[i] < str[now]):
        A[i] = str[now]
        now+=1

# print(A)
print(sum(A))
### BUGGY CODE ###

import numpy as np
S = list(input())
u = 10**9+7
d = len(S)
dp = np.zeros(13, dtype=np.int64)
dp[0] = 1
m = 1

for i in range(d-1,-1,-1):
    tmp = np.zeros(13, dtype=np.int64)
    a = S[i]
    if a=='?':
        for j in range(10):
            c = j*m
            for k in range(13):
                n = (c+k)%13
                tmp[n] += dp[k]
                tmp[n] %= u
    else:
        c = int(a)*m
        for k in range(13):
            n = (c+k)%13
            tmp[n] += dp[k]
            tmp[n] %= u
    m *= 10
    m %= 13
    dp = tmp
print(dp[5])

### FIXED CODE ###

import sys
def input():
    return sys.stdin.readline()[:-1]
S = list(input())
u = 10**9+7
d = len(S)
dp = [0]*13
dp[0] = 1
m = 1

for i in range(d-1,-1,-1):
    tmp = [0]*13
    a = S[i]
    if a=='?':
        for j in range(10):
            c = j*m
            for k in range(13):
                n = (c+k)%13
                tmp[n] += dp[k]
                tmp[n] %= u
    else:
        c = int(a)*m
        for k in range(13):
            n = (c+k)%13
            tmp[n] += dp[k]
            tmp[n] %= u
    m *= 10
    m %= 13
    dp = tmp
print(dp[5])
### BUGGY CODE ###

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

score = 0

while K>0:
    if A>0:
        score += 1
        A-=1
        K-=1
    elif B>0:
        B-=1
        K-=1
    elif C>0:
        score -=1
        C-=1
        K-=1
    else:
        break
print(score)


### FIXED CODE ###

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

score = 0


if K <= A+B:
    score = min(A,K)
else:
    score = A - min(C, (K - (A+B)))


print(score)
### BUGGY CODE ###

#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import *
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    def dfs(x):
        if dp[x] is not None: return dp[x]
        l = []
        for e in edg[x]:
            heappush(l, dfs(e) + 1)
        tmp = 0
        while l:
            t = heappop(l)
            tmp += 1
            if t > tmp:
                tmp = t
        dp[x] = tmp
        return tmp
    n = II()
    edg = [[] for _ in range(n)]
    dp = [None] * n
    for i in range(n - 1):
        a = II() - 1
        edg[a].append(i + 1)
    print(dfs(0))
    return


#main
if __name__ == '__main__':
    solve()


### FIXED CODE ###

#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import *
from bisect import bisect_left, bisect_right
import sys
sys.setrecursionlimit(2147483647)
input = sys.stdin.readline
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10
input=lambda:sys.stdin.readline().rstrip()
#solve
def solve():

    n = int(input())
    edg = [[] for _ in range(n)]
    dp = [None] * n
    for i in range(1,n):
        u = int(input()) - 1
        edg[u].append(i)
        edg[i].append(u)

    def dfs(v,p=-1)->int:
        if (dp[v] is not None): return dp[v]
        if (edg[v] == [p]):
            dp[v] = 0
            return 0
        tmp = []
        for nv in edg[v]:
            if (nv == p): continue
            tmp.append(dfs(nv,v))
        dp[v] = max(1 + i + x for i, x in enumerate(sorted(tmp, reverse=1)))
        return dp[v]
    
    print(dfs(0))
    return


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

n,m  = map(int, input().split())
broken_stairs = []
INF = 1000000007
for i in range(m):
    a = int(input())
    if i > 0:
        if a == broken_stairs[-1] + 1:
            print(0)
            quit()
    broken_stairs.append(a)

dp = [0] * (n + 1)
dp[0] = 1
if 1 not in broken_stairs:
	dp[1] = 1
else:
	dp[1] = 0
for i in range(2, n + 1):
	if i in broken_stairs:
		continue
	dp[i] = dp[i - 1] + dp[i - 2]
	dp[i] %= INF
print(dp[-1])


### FIXED CODE ###

n,m  = map(int, input().split())
INF = 1000000007
broken_stairs = set([int(input()) for i in range(m)])

dp = [0] * (n + 1)
dp[0] = 1
if 1 not in broken_stairs:
	dp[1] = 1
else:
	dp[1] = 0
for i in range(2, n + 1):
	if i in broken_stairs:
		continue
	dp[i] = dp[i - 1] + dp[i - 2]
	dp[i] %= INF
print(dp[n])
### BUGGY CODE ###

n, k, *h = map(int, open(0).read().split())
dp = [float('inf')] * n
dp[0] = 0
for i in range(1, n):
    for j in range(max(0, i-k), i):
        dp[i] = min(dp[j] + abs(h[i] - h[j]), dp[i])
print(dp[n-1])

### FIXED CODE ###

def main():
    n, k, *h = map(int, open(0).read().split())
    dp = [float('inf')] * n
    dp[0] = 0
    for i in range(1, n):
        min_i = max(0, i-k)
        dp[i] = min([dp[j] + abs(h[i] - h[j]) for j in range(min_i, i)])
    print(dp[n-1])
if __name__ == '__main__':
    main()
### BUGGY CODE ###

#from heapq import nsmallest as hp
l,r = map(int,input().split())
tmp = 2019
tmp2 = 0
for i in range(l,min(r+1,l+2018)):
  
  for j in range(i+1,r+1):
    tmp = min(tmp,i*j%2019)
    
  if tmp == 0:
    break

print(tmp)

### FIXED CODE ###

l,r = map(int,input().split())
tmp = 2019
tmp2 = 0
for i in range(l,min(r+1,l+2018)):
  
  for j in range(i+1,min(r+1,l+2018)):
    tmp = min(tmp,i*j%2019)
    
  if tmp == 0:
    break

print(tmp)
### BUGGY CODE ###

import numpy as np
n, k = map(int, input().split())
hlis = np.array(list(map(int, input().split())))
dp = np.zeros(n, dtype=int)
dp[0] = 0
dp[1] = abs(hlis[0] - hlis[1])
for i in range(2,n):
    dp[i] = min(dp[j] + abs(hlis[i] - hlis[j]) for j in range(max(0, i-k), i))
print(dp[n-1])

### FIXED CODE ###

N, K = map(int, input().split())
hlis = list(map(int, input().split()))
dp = [float('inf')]*(N+1)
dp[1] = 0
for i in range(1, N):
    for j in range(1,min(K+1, N-i+1)):
        dp[i+j] = min(dp[i+j], dp[i] + abs(hlis[i-1]-hlis[i+j-1]))
print(dp[-1])
### BUGGY CODE ###

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

kukan = 0
kukan_list = []
for i in range(n - k + 1):
    if kukan < sum(p[i:i + k]):
        kukan = sum(p[i:i + k])
        kukan_list = p[i:i + k]

ans = kukan / 2 + 0.5 * k
print(ans)


### FIXED CODE ###

from collections import deque
import itertools
import time

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

kukan = 0
for i in range(k):
    kukan += p[i]

kukan_max = kukan
for i in range(n - k + 1):
    kukan_max = max(kukan_max, kukan)
    if i+k<n:
        kukan += p[i+k]
        kukan -= p[i]
ans = kukan_max / 2 + 0.5 * k
print(ans)
### BUGGY CODE ###

import bisect

def main():
    n = int(input())
    a = []
    for _ in range(n):
        target = int(input())
        target = 10**9 + 1 - target 
        index = bisect.bisect_left(a, target)
        if index < len(a) and a[index] > target:
            a[index] = target
        else:
            a.append(target)
        a.sort()
    print(len(a))

if __name__ == "__main__":
    main()


### FIXED CODE ###

import bisect

def main():
    n = int(input())
    buf = []
    a = [None] * n
    for i in range(n):
        a[i] = int(input())
    for i in reversed(a):
        index = bisect.bisect_right(buf, i)
        if index < len(buf) and buf[index] > i:
            buf[index] = i
        else:
            buf.append(i)
    print(len(buf))

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

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

for x in range(0, M):
  A.sort()
  A[len(A)-1] = A[len(A)-1]//2

print(sum(A))

### FIXED CODE ###

import heapq

N, M = map(int, input().split())
A = [-int(A) for A in input().split()]
heapq.heapify(A)

for x in range(M):
  most = -heapq.heappop(A)
  most //= 2
  heapq.heappush(A, -most)

print(-sum(A))
### BUGGY CODE ###

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

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

for i in range(M):
    B, C = map(int, input().split())
    A += [C]*B
    
A.sort(reverse=True)

print(sum(A[:N]))

### FIXED CODE ###

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

A = sorted(list(map(int, input().split())), reverse=True)

B = []
for i in range(M):
    b, c = map(int, input().split())
    B.append([b, c])

B.sort(key=lambda x:(-x[1]))

cnt = 0
ans = 0
a = 0
b = 0
while True:
    if b <= M-1 and A[a] <= B[b][1]:
        n = min(B[b][0], N-cnt)
        ans += B[b][1]*n
        cnt += n
        if cnt == N:
            print(ans)
            break
        b += 1
    elif a <= N-1:
        cnt += 1
        ans += A[a]
        if cnt == N:
            print(ans)
            break
        a += 1
### BUGGY CODE ###

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

ans = 1
for i in a:
    ans *= i
if ans > 10**18:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

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

if 0 in a:
   print(0)
   exit()
ans = 1
for i in a:
    ans *= i
    if ans > 10**18:
        print(-1)
        exit()
print(ans)
### BUGGY CODE ###

def solve():
    N = int(input())
    Ps = list(map(int, input().split()))

    def makeBIT(numEle):
        numPow2 = 2 ** (numEle-1).bit_length()
        data = [0] * (numPow2+1)
        return data, numPow2
    def addValue(iA, A):
        iB = iA + 1
        while iB <= numPow2:
            data[iB] += A
            iB += iB & -iB
    def getSum(iA):
        iB = iA + 1
        ans = 0
        while iB > 0:
            ans += data[iB]
            iB -= iB & -iB
        return ans

    data, numPow2 = makeBIT(N)

    iPs = list(range(N))
    iPs.sort(key=lambda iP: Ps[iP])

    ans = 0
    for iP in reversed(iPs):
        v = getSum(iP)
        Bs = []
        for x in range(v-1, v+3):
            if x <= 0:
                L = -1
            elif getSum(numPow2-1) < x:
                L = N
            else:
                maxD = numPow2.bit_length()-1
                L = 0
                S = 0
                for d in reversed(range(maxD)):
                    if S+data[L+(1<<d)] < x:
                        S += data[L+(1<<d)]
                        L += 1<<d
            Bs.append(L)

        num = (Bs[1]-Bs[0])*(Bs[2]-iP) + (iP-Bs[1])*(Bs[3]-Bs[2])
        ans += Ps[iP] * num
        addValue(iP, 1)

    print(ans)


solve()


### FIXED CODE ###

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

iPs = [0] * (N+1)
for iP, A in enumerate(Ps):
    iPs[A] = iP

ans = 0
iLs = list(range(N+1))
iRs = list(range(N+1))
for P in range(1, N+1):
    i = iPs[P]
    iL, iR = iLs[i], iRs[i]
    if iL <= 1:
        iL2 = 0
    else:
        iL2 = iLs[iL-1]
    if iR >= N-2:
        iR2 = N-1
    else:
        iR2 = iRs[iR+1]
    num = 0
    if iL != 0:
        num += (iL-iL2)*(iR-i+1)
    if iR != N-1:
        num += (i-iL+1)*(iR2-iR)
    ans += P * num
    iLs[iR+1] = iL
    iRs[iL-1] = iR

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

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

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

gcd_forward = []
gcd_all = numbers[0]
for i in range(0, N - 1):
  gcd_all = gcd(gcd_all, numbers[i])
  gcd_forward.append(gcd_all)

gcd_backward = []
gcd_all = numbers[-1]
for i in range(N - 1, 0, -1):
  gcd_all = gcd(gcd_all, numbers[i])
  gcd_backward.insert(0, gcd_all)

gcd_forward.insert(0, gcd_backward[0])
gcd_backward.append(gcd_forward[-1])

gcd_max = 1
for i in range(N):
  gcd_max = max(gcd_max, gcd(gcd_forward[i], gcd_backward[i]))
  
print(gcd_max)


### FIXED CODE ###

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

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

gcd_forward = [numbers[0]]
for i in range(1, N - 1):
  gcd_all = gcd(gcd_forward[-1], numbers[i])
  gcd_forward.append(gcd_all)

gcd_backward = [numbers[-1]]
for i in range(N - 2, 0, -1):
  gcd_all = gcd(gcd_backward[-1], numbers[i])
  gcd_backward.append(gcd_all)

gcd_max = 1
for i in range(N):
  gcd_temp = 1
  if (i == 0):
    gcd_temp = gcd_backward[-1]
  elif (i == N - 1):
    gcd_temp = gcd_forward[-1]
  else:
    gcd_temp = gcd(gcd_forward[i - 1], gcd_backward[N - 2 - i])
  gcd_max = max(gcd_max, gcd_temp)
  
print(gcd_max)
### BUGGY CODE ###

k = int(input())
s = input()

mod = 10 ** 9 + 7
s = len(s)
n = k + s


def _fac_inv(_n, _mod):
    _fac = [1] * (_n + 1)
    _inv = [1] * (_n + 1)
    for i in range(_n):
        _fac[i + 1] = _fac[i] * (i + 1) % _mod
    _inv[n] = pow(_fac[n], _mod - 2, _mod)
    for i in range(_n, 0, -1):
        _inv[i - 1] = _inv[i] * i % _mod

    return _fac, _inv


fac, inv = _fac_inv(n, mod)

n25 = [1]
n26 = [1]
for _ in range(n):
    n25.append((n25[-1] * 25) % mod)
    n26.append((n26[-1] * 26) % mod)

ans = 0

for i in range(s, n + 1):
    ans = (ans + (fac[i-1] * inv[s-1] * inv[i - s] * n25[i - s]) * n26[n - i]) % mod

print(ans)


### FIXED CODE ###

k = int(input())
s = input()
s = len(s)

mod = 10 ** 9 + 7
n = k + s


def _fac_inv(_n, _mod):
    _fac = [1] * (_n + 1)
    _inv = [1] * (_n + 1)
    for i in range(_n):
        _fac[i + 1] = _fac[i] * (i + 1) % _mod
    _inv[_n] = pow(_fac[_n], _mod - 2, _mod)
    for i in range(_n, 0, -1):
        _inv[i - 1] = _inv[i] * i % _mod

    return _fac, _inv


fac, inv = _fac_inv(n, mod)

n25 = [1]
n26 = [1]
for _ in range(n-s):
    n25.append((n25[-1] * 25) % mod)
    n26.append((n26[-1] * 26) % mod)

ans = 0

for i in range(s, n + 1):
    ans = (ans + fac[i-1] * inv[s-1] * inv[i-s] * n25[i-s] * n26[n-i]) % mod

print(ans)