#include <stdio.h>
#include <stdlib.h>
int asc(const void *a, const void *b)
{
    return *(int *)a - *(int *)b;
}
int a[200010] = {};
int search(int t, int left, int right)
{
    int count = 0;
    int l = left, r = right;
    int c;
    int ll = -1, rr = -1;
    while (l < r)
    {
        c = (l + r) / 2;
        if (a[c] < t)
        {
            l = c + 1;
        }
        else
        {
            r = c;
        }
        if (l == r && a[l] == t)
        {
            ll = l;
        }
    }
    l = left;
    r = right;
    while (l < r)
    {
        c = (l + r) / 2;
        if (a[c] > t)
        {
            r = c - 1;
        }
        else
        {
            l = c;
        }
        if (l == r && a[r] == t)
        {
            rr = r;
        }
    }
    if (ll == -1)
    {
        count = 0;
    }
    else
    {
        count = rr - ll + 1;
    }
    return count;
}
int main()
{
    int n;
    scanf("%d", &n);
    int t;
    long int ans = 0;
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &t);
        ans += search(-t + i, 0, i - 1);
        a[i] = t + i;
        qsort(a, i, sizeof(int), asc);
    }
    printf("%ld", ans);
    return 0;
}