#include <bits/stdc++.h>
using namespace std;
long long int n, a[200005], b[200005], c[200005], ans;
int main() {
  cin >> n;
  for (long long int i = (long long int)0; i < (long long int)n; i++) {
    cin >> a[i];
    if (i == 0)
      b[i] = a[i];
    else
      b[i] = a[i] + b[i - 1];
  }
  sort(b, b + n);
  for (long long int i = (long long int)0; i < (long long int)n; i++) {
    if (i == 0) {
      if (b[i] == 0) {
        c[i] = 1;
      }
    } else {
      if (b[i] == b[i - 1]) {
        c[i] = c[i - 1] + 1;
      }
    }
    ans += c[i];
  }
  cout << ans << endl;
  return 0;
}
