Buggy python submission (verdict: Runtime Error):
n=int(input())
ans=0
a=list(map(int,input().split()))
now=max(a)
noww=now
ka=n+2*now
matc=[0]*ka
mat2=[0]*ka
for i in range(n):
  matc[now-a[i]]+=1
  mat2[now+a[i]]+=1
  now+=1
#print(matc)
for j in range(noww,noww+n+1):
  ans+=matc[j]*mat2[j]
print(ans)
       
       




Fixed submission:
import numpy as np
n=int(input())
ans=0
a=list(map(int,input().split()))
now=max(a)
noww=now
k=n+2*now
matc=[0]*(n+2)
mat2=[0]*(n+2)
for i in range(n):
  neg=i-a[i]
  pos=i+a[i]
  if neg>=0:
    matc[neg]+=1
  if pos<=n:
    mat2[pos]+=1
  now+=1
#print(matc)
for j in range(n+2):
  ans+=matc[j]*mat2[j]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
ans=0
a=list(map(int,input().split()))
now=max(a)
noww=now
matc=list(0 for i in range(n+2*now))
mat2=list(0 for i in range(n+2*now))
for i in range(n):
  matc[now-a[i]]+=1
  mat2[now+a[i]]+=1
  now+=1
#print(matc)
for j in range(noww,noww+n+1):
  ans+=matc[j]*mat2[j]
print(ans)
       
       




Fixed submission:
import numpy as np
n=int(input())
ans=0
a=list(map(int,input().split()))
now=max(a)
noww=now
k=n+2*now
matc=[0]*(n+2)
mat2=[0]*(n+2)
for i in range(n):
  neg=i-a[i]
  pos=i+a[i]
  if neg>=0:
    matc[neg]+=1
  if pos<=n:
    mat2[pos]+=1
  now+=1
#print(matc)
for j in range(n+2):
  ans+=matc[j]*mat2[j]
print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
ans=0
a=list(map(int,input().split()))
now=max(a)
noww=now
matc=list(0 for i in range(n+2*now))
mat2=list(0 for i in range(n+2*now))
for i in range(n):
  matc[now-a[i]]+=1
  mat2[now+a[i]]+=1
  now+=1
#print(matc)
for j in range(noww,noww+n+10):
  ans+=matc[j]*mat2[j]
print(ans)
       
       




Fixed submission:
import numpy as np
n=int(input())
ans=0
a=list(map(int,input().split()))
now=max(a)
noww=now
k=n+2*now
matc=[0]*(n+2)
mat2=[0]*(n+2)
for i in range(n):
  neg=i-a[i]
  pos=i+a[i]
  if neg>=0:
    matc[neg]+=1
  if pos<=n:
    mat2[pos]+=1
  now+=1
#print(matc)
for j in range(n+2):
  ans+=matc[j]*mat2[j]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
ans=0
a=list(map(int,input().split()))
now=max(a)
noww=now
matc=list(0 for i in range(n+2*now))
mat2=list(0 for i in range(n+2*now))
for i in range(n):
  matc[now-a[i]]+=1
  mat2[now+a[i]]+=1
  now+=1
#print(matc)
for j in range(n+2*noww):
  ans+=matc[j]*mat2[j]
print(ans)
       
       



Fixed submission:
import numpy as np
n=int(input())
ans=0
a=list(map(int,input().split()))
now=max(a)
noww=now
k=n+2*now
matc=[0]*(n+2)
mat2=[0]*(n+2)
for i in range(n):
  neg=i-a[i]
  pos=i+a[i]
  if neg>=0:
    matc[neg]+=1
  if pos<=n:
    mat2[pos]+=1
  now+=1
#print(matc)
for j in range(n+2):
  ans+=matc[j]*mat2[j]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
ans=0
a=list(map(int,input().split()))
now=max(a)
noww=now
matc=list([] for i in range(n+2*now))
mat2=list([] for i in range(n+2*now))
for i in range(n):
  matc[now-a[i]].append(i)
  mat2[now+a[i]].append(i,)
  now+=1
#print(matc)
for j in range(n+2*noww):
  ans+=len(matc[j])*len(mat2[j])
print(ans)
       
       



Fixed submission:
import numpy as np
n=int(input())
ans=0
a=list(map(int,input().split()))
now=max(a)
noww=now
k=n+2*now
matc=[0]*(n+2)
mat2=[0]*(n+2)
for i in range(n):
  neg=i-a[i]
  pos=i+a[i]
  if neg>=0:
    matc[neg]+=1
  if pos<=n:
    mat2[pos]+=1
  now+=1
#print(matc)
for j in range(n+2):
  ans+=matc[j]*mat2[j]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
ans=0
a=list(map(int,input().split()))
now=max(a)
matc=list([] for i in range(n+2*now))
for i in range(n):
  matc[now-a[i]].append([i,0])
  matc[now+a[i]].append([i,1])
  now+=1
matc=filter(lambda x: x != [], matc)
#print(matc)
for j in matc: 
  count0=0
  count1=0
  for k in j:
    if k[1]==0:
      count0+=1
    else:
      count1+=1
  ans+=count0*count1
print(ans)
       
       

Fixed submission:
import numpy as np
n=int(input())
ans=0
a=list(map(int,input().split()))
now=max(a)
noww=now
k=n+2*now
matc=[0]*(n+2)
mat2=[0]*(n+2)
for i in range(n):
  neg=i-a[i]
  pos=i+a[i]
  if neg>=0:
    matc[neg]+=1
  if pos<=n:
    mat2[pos]+=1
  now+=1
#print(matc)
for j in range(n+2):
  ans+=matc[j]*mat2[j]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
ans=0
a=list(map(int,input().split()))
now=max(a)
matc=list([] for i in range(n+2*now))
for i in range(n):
  matc[now-a[i]].append([i,0])
  matc[now+a[i]].append([i,1])
  now+=1
#print(matc)
for j in matc: 
  count0=0
  count1=0
  for k in j:
    if k[1]==0:
      count0+=1
    else:
      count1+=1
  ans+=count0*count1
print(ans)
       
       

Fixed submission:
import numpy as np
n=int(input())
ans=0
a=list(map(int,input().split()))
now=max(a)
noww=now
k=n+2*now
matc=[0]*(n+2)
mat2=[0]*(n+2)
for i in range(n):
  neg=i-a[i]
  pos=i+a[i]
  if neg>=0:
    matc[neg]+=1
  if pos<=n:
    mat2[pos]+=1
  now+=1
#print(matc)
for j in range(n+2):
  ans+=matc[j]*mat2[j]
print(ans)