#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> S(N + 1);
  S[0] = 0;
  for (int i = 0; i < (N); i++) {
    int a;
    cin >> a;
    S[i + 1] = S[i] + a;
  }
  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] - 1 << endl;
  return 0;
}
