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

int		main()
{
	int		N, *A;
	int		count, ans = 0;

	scanf("%d\n", &N);
	A = (int *)calloc((N + 1), sizeof(int));
	for (int i = 1; i <= N; i++)
	{
		scanf("%d ", &A[i]);
	}
	for (int i = 1; i <= N; i++)
	{
		count = 1;
		for (int n = i + A[i] + 1; n <= N; n++)
		{
			if (A[n] == count)
				ans++;
			count++;
		}
	}
	printf("%d\n", ans);
	return (0);
}