#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int A[N];
  int S[N + 1];
  S[0] = 0;
  map<int, int> log;
  log[S[0]]++;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    S[i + 1] = S[i] + A[i];
    log[S[i + 1]]++;
  }
  long long ans = 0;
  for (map<int, int>::iterator it = log.begin(); it != log.end(); ++it) {
    long long tmp = it->second;
    ans += tmp * (tmp - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
