#include <stdio.h>
#include <string.h>
#include<stdlib.h>


int absInt(int value) {

	if (value < 0) value = -value;

	return value;

}

int main(void) {

	int people = 0;

	scanf("%d%*c", &people);

	int** height = (int**)malloc(sizeof(int*) * people);

	height[0] = (int*)malloc(sizeof(int) * 2 * people);

	for (int j = 0; j < people; j++) {

		height[j] = height[0] + j * 2;

	}

	const int numberIndex = 0;

	const int heightIndex = 1;


	for (int i = 0; i < people; i++) {

		height[i][numberIndex] = i + 1;

		scanf("%d%*c", &height[i][heightIndex]);

	}

	int tempHeight = 0;

	int tempNumber = 0;


	int numberDifference = 0;

	int heightSum = 0;

	int count = 0;

	for (int p = 0; p < people; p++) {

		for (int q = p + 1; q < people; q++) {

			numberDifference = absInt(height[p][numberIndex] - height[q][numberIndex]);

			heightSum = height[p][heightIndex] + height[q][heightIndex];

			if (numberDifference == heightSum)count++;

		}

	}

	printf("%d\n", count);

	return 0;
}