#include<bits/stdc++.h>
#define int long long
using namespace std;
int n;
map<int,int>p;
int dem=0;
signed main()
{
cin>>n;
int a[n+1],b[n+1],ans=0;
p[0]=1;
for (int i=1;i<=n;i++)
{
cin>>a[i];
b[i]=(a[i]%n+n)%n;
}
for (int i=1;i<=n;i++)
{
ans+=b[i];
dem=dem+p[ans%n];
p[ans%n]++;
}
cout<<dem;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2RlZmluZSBpbnQgbG9uZyBsb25nIAp1c2luZyBuYW1lc3BhY2Ugc3RkOwppbnQgbjsKbWFwPGludCxpbnQ+cDsKaW50IGRlbT0wOwpzaWduZWQgbWFpbigpCnsKICAgIGNpbj4+bjsKICAgIGludCBhW24rMV0sYltuKzFdLGFucz0wOwogICAgcFswXT0xOwogICAgZm9yIChpbnQgaT0xO2k8PW47aSsrKQogICAgewogICAgICAgIGNpbj4+YVtpXTsKICAgICAgIGJbaV09KGFbaV0lbituKSVuOwogICAgfQogICAgZm9yIChpbnQgaT0xO2k8PW47aSsrKQogICAgewogICAgICAgIGFucys9YltpXTsKICAgICAgICBkZW09ZGVtK3BbYW5zJW5dOyAKICAgICAgICBwW2FucyVuXSsrOwogICAgfQogICAgY291dDw8ZGVtOwp9Cg==