link to problem:Problem - C - Codeforces

link to solution: https://usaco.guide/problems/cf-good-subarrays/solution

I am having trouble understanding the logic behind incrementing the map elements

```
map<int, ll> sumDist;
for(int i=0; i<=n; i++){
sumDist[dp[i]-i]++;
```

Also, how does summing f (f-1)/2 give the final answer?

```
for(pi p: sumDist){
ll f=p.second;
goodArrays+=f*(f-1)/2;
}
```