#include <bits/stdc++.h>
using namespace std;
long long A[200000];
long long S[200001];
long long comb2(int n) { return n * (n - 1) / 2; }
int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < N; i++) {
    S[i + 1] = S[i] + A[i];
  }
  unordered_map<long long, int> cnt;
  for (int i = 0; i <= N; i++) {
    cnt[S[i]]++;
  }
  long long ans = 0;
  for (auto itr : cnt) {
    long long val = itr.second;
    ans += comb2(val);
  }
  cout << ans << endl;
  return 0;
}
