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