peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

if __name__ == '__main__':
    a = [int(i) for i in input().split()]

    print(a[2] - (a[0]-a[1]))
# Judge status: Wrong Answer
n = int(input())
s = list(input())
ans,box = 0,[]
for i in range(n):
  if s[i] == "I":
    ans += 1
  else:
    ans -= 1
  box.append(ans)
print(max(box))
# Judge status: Accepted
a,b=map(int,input().split())
c,d=map(int,input().split())
e=int(input())

n=abs(c-a)
m=b-d
if m<=0:
    print('NO')
elif e>=n/m:
    print('YES')
else:
    print('NO')
# Judge status: Wrong Answer
N,X=map(int,input().split(" "))
L=[int(s) for s in input().split(" ")]

Sum=0
Count=0
while Sum<=X:
    Sum+=L[Count]
    Count+=1
    if Count==N:
        Count=N+1
        break
    
print(Count)
# Judge status: Accepted
s = sorted(input())
if (s[0] == s[1]) and (s[2] == s[3]) and (s[0] != s[2]):
        print('Yes')
elif (s[0] == s[2]) and (s[1] == s[3]) and (s[0] != s[1]):
        print('Yse')
elif (s[0] == s[3]) and (s[1] == s[2]) and (s[0] != s[1]):
        print('Yes')
else:
    print('No')
# Judge status: Accepted
a = input()
if a == "Sunny":
  print("Cloudy")
elif a == "Rainy":
  print("Sunny")
else:
  print("Rainy")
# Judge status: Accepted
N,M=map(int,input().split())
Br=[None]*(2*M)
for i in range(M):
  Br[2*i],Br[2*i+1]=map(int,input().split())
for i in range(N):
  print(Br.count(i+1))
# Judge status: Accepted
N, M, X, Y = map(int, input().split())
x = [int(s) for s in input().split()]
y = [int(s) for s in input().split()]
x.append(X)
y.append(Y)
print('No War') if max(x) < min(y) else print('War')
# Judge status: Wrong Answer
import fractions

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


lcm = a[0]
for i in range(1, N):
    lcm = lcm * a[i] // fractions.gcd(lcm, a[i])


M2=2*M

ans=0
if M2>=lcm:
    M2-=lcm
    ans+=1
    ans+=M2//(lcm*2)
    
print(ans)
# Judge status: Accepted
n, k = map(int, input().split())
if n % k == 0:
    print(0)
else:
    print(1)
# Judge status: Accepted
n=int(input())
a=sorted(list(map(int,input().split())),reverse=True)
h,w,i=0,0,0
while i<n-1:
    if a[i]==a[i+1]:
        if h==0:
            h=a[i]
            i+=1 #
        else:
            w=a[i]
            break
    i+=1
print(h*w)
# Judge status: Accepted

S = input()
T = input()

len_t = len(T)
G = []

for i in range(len(S)-len_t+1):
  valid = True
  
  for j in range(len_t):
    if S[i+j] != "?" and S[i+j] != T[j]:
      valid = False

  if valid:
    SL = list(S)
    for j in range(len_t):
      SL[i+j] = T[j]
    G.append("".join(SL).replace("?", "a"))

print(min(G, default="UNRESTORABLE"))
# Judge status: Accepted
S = input()
sum = 0
for i in range(3):
    if S[i]=="R":
        sum += 1
if sum == 2 and S[1] == "S":
        sum = 1
print(sum)
# Judge status: Wrong Answer
# Input(n = num of monsters/k = num of special attacks)
n, k = input().split()
a = list(map(int, input().split()))

# Variable declarations
n = int(n)
k = int(k)
attacks = 0

# Calculating how many attacks fennec needs.
for i in range(n-k):
    if k > n:
        break
    attacks += a[i]

# Printing how many attacks fennec needs.
print(attacks)
# Judge status: Accepted
n = int(input())

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

k = s.copy()

k.sort(reverse = False)

t = 0

for i in range(n):
    if s[i] != k[i]:
        t += 1
        
if t<3:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
K, S = map(int, input().split())
result = 0
for x in range(K+1):
    for y in range(K+1):
        if 0 <= S - x - y <= K:
            result += 1
print(result)
# Judge status: Accepted
import numpy as np

S = np.array(list(input()))
T = np.array(list(input()))

print(np.count_nonzero(S != T))
# Judge status: Accepted
n = int(input())
ans = [0] * n

cnt = 0
for x in range(1, 100):
  for y in range(1, 100):
    for z in range(1, 100):
      f = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
      if f <= n:
        ans[f - 1] += 1
ans.append(cnt)

for j in range(n):
  print(ans[j])
# Judge status: Wrong Answer
import math
N,K=map(int,input().split())
A=list(map(int,input().split()))
saishou=A.index(1)
if saishou==0:
    answer=math.ceil((N-1)/(K-1))
    print(answer)
elif saishou+1<=K:
    answer=1+math.ceil((N-1-saishou)/(K-1))
    print(answer)
elif N-saishou<=K:
    answer=math.ceil(saishou/(K-1))+1
    print(answer)
else:
    print(math.ceil(saishou/(K-1))+math.ceil((N-1-saishou)/(K-1)))
# Judge status: Accepted
n=int(input())
m=[]
m.append(int(input()))
count=1
for i in range(n-1):
  k=int(input())
  if k<=m[-1]:
    m.append(k)
    count+=1
  else:
    r=count-1
    l=0
    while l+1<r:
      try1=(r+l)//2
      if m[try1]>=k:
        l=try1
      else:
        r=try1
    if m[l]>=k:
      m[r]=k
    else:
      m[l]=k
print(count)
# Judge status: Accepted
d=int(input())
if d==25:
    print('Christmas')
elif d==24:
    print('Christmas Eve')
elif d==23:
    print('Christmas Eve Eve')
else:
    print('Christmas Eve Eve Eve')
# Judge status: Accepted
a = int(input())
b = int(input())
if a!=1 and b!=1:
    print(1)
elif a!=2 and b!=2:
    print(2)
else:
    print(3)
# Judge status: Accepted
h,n = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
    h -= a[i]
if h <= 0:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
D,N=map(int, input().split())
d = 1
for i in range(D):
  d *= 100
if N==100:
  N += 1
print(d*N)
# Judge status: Accepted
n,a,b=list(map(int, input().split()))
C=10**9+7

def perm(a,b):
    tmp=1
    for i in range(b):
        tmp*=a-i
        tmp=tmp%C
    return tmp

cta=perm(n,a)*pow(perm(a,a),C-2,C)
ctb=perm(n,b)*pow(perm(b,b),C-2,C)

ans=pow(2,n,C)-1-cta-ctb
print(ans%C)
# Judge status: Wrong Answer
n, a, b = [int(w) for w in input().split()]
if (a + b) % 2 == 0:
    ans = (b - a) // 2
else:
    ans = min(b - 1, n - a)
print(ans)
# Judge status: Accepted
from collections import*
n,m,*d=map(int,open(0).read().split())
a=Counter(d[:n])
for b,c in zip(d[n::2],d[n+1::2]):a[c]+=b
s=0
for k, v in sorted(a.items())[::-1]:
 if n<v:exit(print(s+k*n))
 n-=v;s+=k*v
# Judge status: Accepted
from collections import Counter
n = int(input())
a = [min(x//400, 8) for x in map(int, input().split())]
a = Counter(a)

if len(a) == 1 and a[8] != 0:
    min_a = 1
    max_a = a[8]
elif a[8] != 0:
    min_a = len(a)-1
    max_a = min_a+a[8]
else:
    min_a = max_a = len(a)
print(min_a, max_a)
# Judge status: Wrong Answer
a,v = map(int,input().split())
b,w = map(int,input().split())
t = int(input())
ans = 0
if a == b:
    ans = 1
if v == w:
    ans = 1
elif v>w and abs(a-b)/(v-w) <= t :
    ans = 1
if ans == 0:
    print("NO")
else:
    print("YES")
# Judge status: Accepted
N = input('')
a =['a', 'b','c','d', 'e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
A = ['A', 'B','C','D', 'E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
if N in a:
  print('a')
else:
  print('A')
# Judge status: Accepted
N, L = map(int, input().split())
l = []
for i in range(N):
    s = input()
    l.append(s)
l.sort()
for i in l:
    print(f"{i}", end="")
print()
# Judge status: Accepted
n = int(input())

if n % 2 == 1:
    print(0)
elif n % 2 == 0:
    ans = 0
    k = 10
    while n >= k:
        ans += n//k
        k *= 5
        
    print(ans)
# Judge status: Accepted
n,m=map(int,input().split())
if(n==m):
  print('Yes')
else:
  print('No')
# Judge status: Accepted
N = int(input())
T,A = map(int, input().split())
H = list(map(int, input().split()))

x = 0
temp = float('inf')
ans = 0
tmp = 0
for i in range(N):
    x = T - H[i]*0.006
    tmp = abs(x-A)
    if tmp < temp:
        temp = tmp
        ans = i+1

print(ans)
# Judge status: Accepted
n = int(input())
num_list = []
for _ in range(n):
    num_list.append(int(input()))

copy =  num_list.copy()
copy.sort()
maximum = copy[-1]
second = copy[-2]

for i in num_list:
    if i == maximum:
        print(second)
    else:
        print(maximum)
# Judge status: Wrong Answer
def iroha():
    a, b, c = map(int, input().split())
    if a == b == c:
        print(1)
    elif a != b != c:
        print(3)
    elif a == b or b == c or a == c:
        print(2)

if __name__ == "__main__":
    iroha()
# Judge status: Accepted
n=int(input())
if n==1:
  print(0)
else:
  print(1)
# Judge status: Accepted
S = input()
count = 0
koremade = 0
for i in range(0,len(S)):
    if S[i] in 'ACGT':
        count += 1
        if i == len(S)-1:
           if koremade <= count:
               koremade = count 
    else:
        if koremade <= count:
            koremade = count
        count = 0
print(koremade)
# Judge status: Accepted
# https://atcoder.jp/contests/abc176/tasks/abc176_b
n = int(input())
if n % 9 == 0:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
# AtCoder Grand Contest 037
# A - Dividing a String

S=input()
ans=set()
for i in range (len(S)):
    a=S[i]
    if a not in ans:
        ans.add(a)
    else:
        for j in range(i+1,len(S)):
            a=S[i:j]
            if a not in ans:
                ans.add(a)
                break
            else:
                continue
# print(ans)
print(len(ans))
# Judge status: Accepted
C = ord(input())
print(chr(C+1))
# Judge status: Accepted
def main():
    N, M = map(int, input().split())

    if N == 1 or M == 1:
        if N == 1 and M == 1:
            print(1)
            return
        print(N*M-2)
        return

    if N == 2 or M == 2:
        print(0)
        return

    print((N-2)*(M-2))

if __name__ == '__main__':
    main()
# Judge status: Accepted
n=int(input())
ans=0
#it is the power of every prime number
#and as z is always a prime numer we should not bother about
# combiations of prime numer dividing N
for i in range(2,1000010):
	power=0
	j=1
	if(n%i==0):
		while(n%i==0):
			power+=1
			n=(n//i)
		while(power>=j):
			power-=j
			j+=1
			ans+=1
if(n>1):
	ans+=1
print(ans)
# Judge status: Accepted
a,b,c=map(int,input().split())
print('Yes' if a<=c<=b else 'No')
# Judge status: Wrong Answer
N = list(input())
if N[:-1] == "3":
    print("bon")
elif N[:-1] in ["0","1","6","8"]:
    print("pon")
else :
    print("hon")
# Judge status: Wrong Answer
from collections import deque
n = int(input())
a = [int(i) for i in input().split()]
b = deque()
if n % 2 == 0:
    for i in a:
        if i % 2 == 0:
            b.appendleft(i)
        else:
            b.append(i)
else:
    for i in a:
        if i % 2 == 0:
            b.append(i)
        else:
            b.appendleft(i)
print(*b)
# Judge status: Accepted
n, k = map(int, input().split())
ans = 0
mod = 10 ** 9 + 7

n_min = sum([i for i in range(0, k-1)])
n_max = sum([n - i for i in range(0, k-1)])

for i in range(k-1, n+1):
  n_min += i
  n_max += n - i
  ans += n_max - n_min + 1
    
print(ans % mod)
# Judge status: Accepted

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

ok = [True] * (N + 1)
for a, b in X:
    ok[a] &= H[a - 1] > H[b - 1]
    ok[b] &= H[a - 1] < H[b - 1]

print(sum(ok[1:]))
# Judge status: Accepted
n = int(input())
ph = 0
pl = 10**10
mh = -10**10
ml = 10**10
for _ in range(n):
  x,y = map(int,input().split())
  ph = max(ph,x+y)
  pl = min(pl,x+y)
  mh = max(mh,x-y)
  ml = min(ml,x-y)
print(max(ph-pl,mh-ml))
# Judge status: Accepted
import numpy as np
from sys import stdin
from copy import deepcopy
from functools import reduce
from fractions import gcd
import math
import itertools
from collections import Counter
from itertools import chain  ##list(chain.from_iterable(l)) ##flatten
from heapq import heappush, heappop

"""
N = int(input())
A, B = map(int,input().split())
A = list(map(int,input().split())) ## 横一列
A = [int(input()) for _ in range(N)] ## 縦一列
lst = [list(map(int,input().split())) for i in range(M)] ## 二次元
"""

H = int(input())
n_bin = len(bin(H)[2:])

ans = 2 ** n_bin - 1

print(ans)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
A_re = []

for i in range(N):
  num = A[i]
  A_re.append([num, i+1])
  
A_re.sort()

Ans = []
for j in range(N):
  ans = A_re[j][1]
  Ans.append(ans)
  
print(Ans)
# Judge status: Wrong Answer
a=int(input())
b=int(input())
c=[1,2,3]
c.remove(a)
c.remove(b)
print(c)
# Judge status: Wrong Answer
s = input()
if s[0]=="A" and s[2:-1].count("C")==1 and s[-1]!=1:
  print("AC")
else:
  print("WA")
# Judge status: Accepted
S = input()
ans = None
for c in 'abcdefghijklmnopqrstuvwxyz':
    if c not in S:
        ans = c
        break
print(ans)
# Judge status: Accepted
def actual(a, b):
    towers = [1]
    for x in range(2, 999 + 1):
        towers.append(towers[-1] + x)

    for i in range(len(towers)):
        west_tower_height = towers[i]
        east_tower_height = towers[i + 1]

        assert east_tower_height > west_tower_height

        diff = east_tower_height - west_tower_height

        if diff == (b - a):
            return east_tower_height - b

a, b = map(int, input().split())
print(actual(a, b))
# Judge status: Accepted

# input
N = int(input())

# initialization
ans = 0

# count
for i in range(1, N+1):
    if not i%3==0 and not i%5==0:
        ans += i

# output
print(ans)
# Judge status: Accepted
N = int(input())
if N>=30:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
k=int(input())
i=0
while a>=b:
    b*=2
    i+=1
  

while b>=c:
        c*=2
        i+=1

if a<b and b<c and i<=k:
    print("Yse")
else:
    print("No")
# Judge status: Accepted
N = int(input())

mod = 10**9+7
def p(a,n):
    ans  = 1
    for i in range (n):
        ans = ans * a % mod
    return ans

print((p(10,N)+p(8,N) - 2* p(9,N))%mod)
# Judge status: Accepted
a, b = map(int, input().split())
 
if a>b:
  print(a-1)
else:
  print(a)
# Judge status: Accepted
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def main():
    A, B, C = map(int, input().split())


    print(max(0, C-(A-B)))


if __name__ == "__main__":
    main()
# Judge status: Accepted
def GCM(x,y):
  if x%y==0:
    return y
  else:
    return GCM(y,x%y)
  
X = int(input())
print(360//GCM(360,X))
# Judge status: Accepted
def main():
    K = int(input())

    x = 7 % K
    s = set()
    i = 1

    while True:
        # 割り切れる
        if x == 0:
            print(i)
            return

        # 割り切れない、無限ループ
        if x in s:
            print(-1)
            return

        s.add(x)
        x = (x * 10 + 7) % K
        i += 1


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
n=int(input())
k=0
c=0
for i in range(n):
  a,b=map(int,input().split())
  if(a==b):
      k+=1
      if(k>=3):
          c=1
  else:
      k=0

if(c==1):
  print("YES")
else:
  print("NO")
# Judge status: Accepted
S=input()
T=input()

N=len(S)
F=False
for _ in range(N):
    S=S[-1]+S[:-1]
    F|=(S==T)

if F:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
def check(a,b):
  if a<b:
    return 'up'
  if a>b:
    return 'down'
  return ''

def solve():
  ans = 1
  N = int(input())
  A = list(map(int, input().split()))
  ud = ''
  for i in range(N-1):
    a = check(A[i],A[i+1])
    if ud=='' or ud==a:
      ud = a
      continue
    if a=='':
      continue
    ans += 1
    ud = ''
  return ans
print(solve())
# Judge status: Accepted
S = list(input())
S.reverse()
S = ''.join(S)
st = ['maerd','remaerd','esare','resare']
ans = 'YES'
while S != '':
    if S[0:5] in st:
        S = S[5:]
    elif S[0:6] in st:
        S = S[6:]
    elif S[0:7] in st:
        S = S[7:]
    else:
        ans = 'NO'
        break
print(ans)
# Judge status: Accepted
n=int(input())
arr=list(map(int,input().split()))
arr=sorted(arr,reverse=True)
ans=0
for i in range(1,n):
  ans+=arr[i//2]
print(ans)
# Judge status: Accepted
from decimal import Decimal

a, b, c = map(str,input().split())

if (Decimal(a).sqrt() + Decimal(b).sqrt()) < Decimal(c).sqrt():
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
N = int(input())
S = str(input())
count = 0

Rlist = list()
Blist = list()
Glist = list()

for i in range(1, len(S)):
    if S[i] == "R":
        Rlist.append(i + 1)
    elif S[i] == "G":
        Glist.append(i + 1)
    else:
        Blist.append(i + 1)

for i in range(len(Rlist)):
    for j in range(len(Blist)):
        for k in range(len(Glist)):
            if j - i != k - j:
                count += 1


print(count)
# Judge status: Wrong Answer
n, m, x = map(int, input().split())
C = [list(map(int, input().split())) for _ in range(n)]
 
import itertools as it
import math
 
cost = math.inf
for comb in it.chain(*(it.combinations(C, r) for r in range(1, n+1))):
    print(comb)
    print(*comb)
    c, *a = map(sum, zip(*comb))
    print(c,a)
    if c < cost and min(a) >= x:
        cost = c
 
print(-1 if cost is math.inf else cost)
# Judge status: Wrong Answer
from itertools import accumulate

def main():
    N = int(input())
    people = list(input())

    wests = list(accumulate([0]+people, lambda total, x: total + (1 if x == "W" else 0)))[1:]
    easts = list(accumulate([0]+people, lambda total, x: total + (1 if x == "E" else 0)))[1:]

    def linearsearch():
        easts_total = easts[-1]
        for i in range(1, N-1):
            yield wests[i-1] + easts_total - easts[i+1]

    print(min(linearsearch()))

main()
# Judge status: Accepted
S = input()
if "A" in S and "B" in S:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
n,x,t = map(int, input().split())
print(t * (n // x + 1) if n % x != 0 else t * (n // x))
# Judge status: Accepted
a,b=map(int,input().split())
def get_prime_dic(n):
    dic = {}
 
    i = 2
    while i * i <= n:
        while n % i == 0:
            n //= i
            if i in dic:
                dic[i] += 1
            else:
                dic[i] = 1
        i += 1
 
    if n > 1:
        dic[n] = 1
    return dic
c=get_prime_dic(a)
d=get_prime_dic(b)
ans=1

ans+=len(set(c)&set(d))

print(ans)
# Judge status: Accepted
n=int(input())
X=list(map(int,input().split()))
S=list(sorted(X))
L=S[n//2-1]
R=S[n//2]
if L==R:
    for i in range(n):
        print(L)
else:
    for x in X:
        if x<=L:
            print(R)
        else:
            print(L)
# Judge status: Accepted
# -*- coding: utf-8 -*-
n = int(input())
k = int(input())
x = int(input())
y = int(input())
if n > k:
    ans = (k*x) + (n-k)*y
else:
    ans = (n*x)
print(ans)
# Judge status: Accepted
# -*- coding: utf-8 -*-
N = int(input())
S = input()

import collections
n_frq_dict = collections.defaultdict(int)
for s in S:
    n_frq_dict[s] += 1

mod=10**9+7
ret = 1
for frq in n_frq_dict.values():
    ret *= frq + 1
    ret %= mod
    
print(ret - 1)
# Judge status: Accepted
n,k = map(int,input().split())
a=list(map(int,input().split()))
if (n-1)%(k-1)==0:
    print((n-1)//(k-1))
else:
    print((n-1)//(k-1)+1)
# Judge status: Accepted

N=int(input())

if N%2==0 :
    print(N//2)
else :
    print(N//2+1)
# Judge status: Accepted
X, A, B = map(int,input().split())
if A >= B: print("delicious")
elif A + X < B: print("dangerous")  
else: print("safe")
# Judge status: Wrong Answer
x=input().split()
n=int(x[0])
m=int(x[1])
p=[]
ref=[]
for k in range(m):
  x=input().split()
  p.append(int(x[0]))
  ref.append(x[1])
first=[-1]*(n+1)
penalties=[0]*(n+1)
for k in range(m):
  prob=p[k]
  outcome=ref[k]
  if first[prob]==-1:
    if outcome=='AC':
      first[prob]=k
    else:
      penalties[prob]+=1
pb=0
pen=0
for k in range(n+1):
  if first[k]!=-1:
    pb+=1
    pen+=penalties[prob]
print(pb,pen)
# Judge status: Accepted
n,m = map(int,input().split())
if n > m:
  (n,m) = (m,n)
if n == 1 and m == 1:
  print(1)
elif (n == 1 and m == 2) or (n == 2 and m == 2) or (n == 2 and m == 3):
  print(0)
elif (n == 1):
  print(m-2)
else:
  print((n-2)*(m-2))
# Judge status: Wrong Answer
n = int(input())
nlen =len(str(n))
ans = 0
 
if n <= 9:
  print(n)
else:
  for i in range(1,nlen):
    if i % 2 == 1:
      ans += 10 ** i -10 ** (i-1)
  if nlen % 2 == 1:
    ans = ans + (n - 10**(nlen-1) + 1)
    print(str(n - 10**(nlen-1) + 1))
  print(ans)
# Judge status: Accepted
# -*- coding utf-8 -*-

MOD = 10 ** 9 + 7
import math

n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]
s = sum([math.sqrt((xy[i][0] - xy[j][0]) ** 2 + (xy[i][1] - xy[j][1]) ** 2) for i in range(n) for j in range(n)])

ans = s / n

print(ans)
# Judge status: Wrong Answer
N, M = map(int, input().split())
PYlist = [tuple(map(int, input().split())) for _ in range(M)]
from copy import deepcopy
PYsorted = sorted(deepcopy(PYlist), key=lambda x: x[1])
print(PYlist)
print(PYsorted)


def zero_ume(num: int) -> str:
    return (6 - len(str(num))) * "0" + str(num)


now_ken = 0
ans_dict = {}
for p, y in PYsorted:
    if p != now_ken:
        now_num = 1
        now_ken = p
    else:
        now_num += 1
    ans_dict[(p, y)] = zero_ume(p) + zero_ume(now_num)

for py in PYlist:
    print(ans_dict[py])
# Judge status: Wrong Answer
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
c = Counter(A)
v = sorted([key for key, value in c.items() if value != 1], reverse=True)
if len(v) >= 2:
    print(v[0] * v[1])
else:
    print(0)
# Judge status: Wrong Answer
a, b, c, d = map(int, input().split())
if a//d + 1 >= c//b :
  print('Yes')
else:
  print('No')
# Judge status: Accepted
n = input()
if n[-1] == "3":
    print("bon")
elif n[-1] == "0" or n[-1] == "1" or n[-1] == "6" or n[-1] == "8":
    print("pon")
else:
    print("hon")
# Judge status: Wrong Answer
s = input()
if s[0] == s[2] and s[0] != s[1] and s[1] != s[2]:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
def f(x):
    return a * x // b - a * (x // b)

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

if n >= b -1:
    print(f(b-1))
else:
    print(f(n))
# Judge status: Accepted
import numpy as np

d = int(input())
c = list(map(int, input().split()))
c_sum = sum(c)
s = [[] for _ in range(d)]
for i in range(d):
  s[i] = list(map(int, input().split()))
  
last = [0 for _ in range(26)]
plan = [-1 for _ in range(d)]

def loss(today):
  sum = 0
  for i in range(26):
    sum += c[i-1] * (today - last[i-1])
  return sum
  
  
v = 0
for today in range(1, d+1):
  t = np.argmax([s[today-1][i] - c_sum + c[i] for i in range(26)])
  t += 1
  last[t-1] = today
  plan[today-1] = t
  print(t)
# Judge status: Accepted
N = int(input())
words_set = set()
words_list = []
OK = True
for _ in range(N):
    s = input()
    words_list.append(s)
    words_set.add(s)
# print(words_list)
# print(words_set)
last_word = words_list[0][-1]
# print(last_word)
for i in range(1, N):
    if last_word == words_list[i][0]:
        last_word = words_list[i][-1]
    else:
        OK = False
        break

if OK and len(words_list) == len(words_set):
    print('Yes')
else:
    print('No')
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))

if len(A)==len(set(A)):
    print("YES")
else:
    print("NO")
# Judge status: Accepted
A, B, C, K = map(int, input().split())

if K <= A:
  max = K

if A < K <= A + B:
  max = A

if A + B < K:
  max = A - (K - A - B)

print(max)
# Judge status: Accepted
n, a, b = map(int, input().split())
s = input()

oversea = 0
c = [False for i in range(n)]
cnt = 0
for i in range(n):
	if s[i] == "a":
		if cnt < a+b:
			c[i] = True
			cnt += 1
	if s[i] == "b":
		if cnt < a+b and oversea < b:
			c[i] = True
			oversea += 1
			cnt += 1
for i in c:
	if i:
		print ("Yes")
	else:
		print ("No")
# Judge status: Accepted
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

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

d = {}
for a in A:
    if a not in d.keys():d[a] = 0
    d[a] += 1
s = sum(A)
q = int(input())
for i in range(q):
    b,c = map(int,input().split())
    if b in d.keys():
        s += d[b]*(c-b)
        if c not in d.keys():d[c] = 0
        d[c] += d[b]
        d[b] = 0
    print(s)
# Judge status: Accepted
N, K = map( int, input().split() )

import math
print( 1 + math.ceil( ( N - K ) / ( K - 1 ) ) )
# Judge status: Accepted
#j-i=Ai+Aj Ai+i=-Aj+j
#Li=Ai+i
#Ri=-Ai+i
#とおくと、Li=Rjとなるとき、Aiが正なので、必ずi<jとなる
from collections import defaultdict

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

L=defaultdict(int)
R=defaultdict(int)

for i in range(n):
	L[A[i]+i+1]+=1
	R[-A[i]+i+1]+=1

r=0
for k,v in L.items():
	j=R[k]
	r+=v*j

print(r)