import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();

        Map<Long, Long> countMap = new HashMap<>();
        
        for (int i = 0; i < n; i++) {
            int ai = in.nextInt(); 
            Long key = (long) ai - i;
            countMap.put(key, countMap.getOrDefault(key, 0L) + 1L);
        }

        Long count = 0L;

        for (Long freq : countMap.values()) {
            count += freq * (freq - 1) / 2;
        }

        System.out.println(count);
    }
}