Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():

    N = int(input())
    num = [i for i in range(1, N+1)]
    A = list(map(int, input().split()))
    d=defaultdict(int)
    cnt=0
    for k,v in enumerate(A):
        d[k+v]+=1
        cnt+=d[k-v]

    print(cnt)


resolve()

Fixed submission:
#!/usr/bin/python3
# import bisect
from collections import Counter, deque, OrderedDict,defaultdict
# from copy import copy, deepcopy
# from functools import reduce
# from heapq import heapify, heappop, heappush
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import statistics # Pythonのみ
# import string
import unittest
from io import StringIO
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():

    N = int(input())
    A = list(map(int, input().split()))
    d=defaultdict(int)
    cnt=0
    for k,v in enumerate(A):
        d[k+v]+=1
        cnt+=d[k-v]

    print(cnt)


resolve()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():

    N = int(input())
    num = [i for i in range(1, N+1)]
    A = list(map(int, input().split()))
    minus = [num[i]-A[i] for i in range(N)]
    plus = [num[i]+A[i] for i in range(N)]
    cnt=0
    for j in range(N):
        for i in range(j):
            if minus[j]==plus[i]:
                cnt+=1
    print(cnt)


resolve()

Fixed submission:
#!/usr/bin/python3
# import bisect
from collections import Counter, deque, OrderedDict,defaultdict
# from copy import copy, deepcopy
# from functools import reduce
# from heapq import heapify, heappop, heappush
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import statistics # Pythonのみ
# import string
import unittest
from io import StringIO
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():

    N = int(input())
    A = list(map(int, input().split()))
    d=defaultdict(int)
    cnt=0
    for k,v in enumerate(A):
        d[k+v]+=1
        cnt+=d[k-v]

    print(cnt)


resolve()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():

    N = int(input())
    num = [i for i in range(1, N+1)]
    A = list(map(int, input().split()))
    minus = [num[i]-A[i] for i in range(N)]
    plus = [num[i]+A[i] for i in range(N)]
    cnt=0
    for j in range(N):
        for i in range(j):
            if minus[j]==plus[i]:
                cnt+=1
    print(cnt)


resolve()

Fixed submission:
#!/usr/bin/python3
# import bisect
from collections import Counter, deque, OrderedDict,defaultdict
# from copy import copy, deepcopy
# from functools import reduce
# from heapq import heapify, heappop, heappush
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import statistics # Pythonのみ
# import string
import unittest
from io import StringIO
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():

    N = int(input())
    A = list(map(int, input().split()))
    d=defaultdict(int)
    cnt=0
    for k,v in enumerate(A):
        d[k+v]+=1
        cnt+=d[k-v]

    print(cnt)


resolve()