#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n, a[N];
map<long long, long long> mp;
int main() {
  scanf("%d", &n);
  mp[0] = 1;
  long long sum = 0, cnt = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    sum += (long long)a[i];
    cnt += mp[sum];
    mp[sum]++;
    cout << sum << ',' << cnt << ',' << mp[sum] << endl;
  }
  printf("%lld", cnt);
}
