#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<long long> S(N), a(N);
  for (int i = 0; i < (N); i++) cin >> a[i];
  S[0] = a[0];
  for (int i = 1; i < N; i++) {
    S[i] = S[i - 1] + a[i];
  }
  long long res = 0;
  map<int, int> mp;
  for (int i = N - 1; i >= 0; i--) {
    res += mp[S[i]];
    mp[S[i]]++;
  }
  cout << res + mp[0] << endl;
  return 0;
}
