#include <bits/stdc++.h>
using namespace std;
long long a[200005];
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    a[0] = 0;
    long long x;
    long long sum = 0;
    map<long long, long long> mp;
    for (int i = 1; i <= n; i++) {
      scanf("%lld", &x);
      a[i] = a[i - 1] + x;
      if (a[i] == 0) {
        sum++;
        continue;
      }
      mp[a[i]]++;
      if (mp[a[i]] > 1) {
        sum += mp[a[i]] - 1;
        int j = i;
        while (a[j - 1] == 0) {
          sum++;
          j--;
        }
      }
    }
    printf("%lld\n", sum);
  }
  return 0;
}
