#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, i, j, dis, N, M, d, p, X, Y;
  long long int ans = 0;
  cin >> N;
  vector<long long int> A(N);
  vector<long long int> sum(N);
  for (i = 0; i < N; i++) {
    cin >> A[i];
    ans += A[i];
    sum[i] = ans;
  }
  sort(sum.begin(), sum.end());
  int ret;
  ret = 0;
  long long int as = 0;
  i = 0;
  j = -1;
  for (i = 0; i < N - 1; i++) {
    if (sum[i] != sum[i + 1]) {
      as += (i - j) * (i - j - 1) / 2;
      j = i;
    }
  }
  as += (N - 1 - j) * (N - 2 - j) / 2;
  for (i = 0; i < N; i++) {
    if (sum[i] == 0) {
      as++;
    }
  }
  cout << as << endl;
  return 0;
}
