class Map(dict):

    default_value = 0



    def __missing__(self, key):

        self[key] = self.default_value

        return self.default_value





def main():

    int(eval(input()))



    d = Map()

    ans = 0

    for i, height in enumerate(input().split()):

        height = int(height)

        d[i + height] += 1

        ans += d[i - height]



    return ans





if __name__ == '__main__':

    print((main()))



# 大いに参考にした。

# https://kmjp.hatenablog.jp/entry/2020/05/03/1030

class Map(dict):

    def __missing__(self, key):

        return 0





def main():

    int(eval(input()))



    d = Map()

    ans = 0

    for i, height in enumerate(input().split()):

        height = int(height)

        d[i + height] += 1

        ans += d[i - height]



    return ans





if __name__ == '__main__':

    print((main()))



# 大いに参考にした。

# https://kmjp.hatenablog.jp/entry/2020/05/03/1030

class Map(dict):
    default_value = 0

    def __missing__(self, key):
        self[key] = self.default_value
        return self.default_value


def main():
    int(eval(input()))
    d = Map()
    ans = 0
    for i, height in enumerate(input().split()):
        height = int(height)
        d[i + height] += 1
        ans += d[i - height]
    return ans


if __name__ == "__main__":
    print((main()))
# 大いに参考にした。
# https://kmjp.hatenablog.jp/entry/2020/05/03/1030

class Map(dict):
    def __missing__(self, key):
        return 0


def main():
    int(eval(input()))
    d = Map()
    ans = 0
    for i, height in enumerate(input().split()):
        height = int(height)
        d[i + height] += 1
        ans += d[i - height]
    return ans


if __name__ == "__main__":
    print((main()))
# 大いに参考にした。
# https://kmjp.hatenablog.jp/entry/2020/05/03/1030

-    default_value = 0 - -        self[key] = self.default_value -        return self.default_value +        return 0