#include <bits/stdc++.h>
using namespace std;
long long comb2(long long n) {
  if (n == 0) return 0;
  return n * (n - 1) / 2;
}
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int(i) = (0); (i) < (N); ++(i)) cin >> A[i];
  vector<long long> S(N + 1);
  S[0] = 0;
  for (int(i) = (0); (i) < (N); ++(i)) S[i + 1] = S[i] + A[i];
  map<int, int> mp;
  for (auto const& s : S) {
    if (mp.count(s) > 0)
      mp[s]++;
    else
      mp[s] = 1;
  }
  long long ans = 0;
  for (auto it = mp.begin(); it != mp.end(); ++it) {
    ans += comb2((long long)it->second);
  }
  cout << ans << endl;
  return 0;
}
