#include <bits/stdc++.h>
const int inf = 1e9 + 7;
const int mod = 1e9 + 7;
using namespace std;
int main() {
  int N;
  long long A[200000];
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  partial_sum(A, A + N, A);
  sort(A, A + N);
  int ans = 0;
  int idx = 0;
  while (idx < N) {
    int cnt = 1;
    while (idx + 1 < N && A[idx] == A[idx + 1]) {
      idx++;
      cnt++;
    }
    if (A[idx] == 0LL) {
      ans += cnt;
    }
    ans += cnt * (cnt - 1) / 2;
    idx++;
  }
  cout << ans << endl;
  return 0;
}
