#include <bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main() {
  int n;
  arr[0] = 0;
  while (cin >> n) {
    for (int i = 1; i <= n; i++) {
      int k;
      scanf("%d", &k);
      arr[i] = arr[i - 1] + k;
    }
    map<int, int> ma;
    map<int, int> mb;
    long long ans = 0;
    for (int i = 0; i <= n; i++) {
      ma[arr[i]]++;
    }
    for (int i = 0; i <= n; i++) {
      if (mb[arr[i]]) continue;
      mb[arr[i]] = 1;
      ans += (ma[arr[i]] - 1) * (long long)ma[arr[i]] / 2;
    }
    cout << ans << endl;
  }
  return 0;
}
