#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  vector<int>(A);
  vector<int>(B);
  map<int, long long> S;
  cin >> N;
  (A).push_back((0));
  (B).push_back((0));
  for (int x = 0; x < (N); x++) {
    int aa;
    cin >> aa;
    (A).push_back(aa);
    ;
    (B).push_back((B.at(x) + A.at(x + 1)));
    S[B.at(x + 1)]++;
  }
  long long ans;
  if (S[0] == 1) {
    ans = 1;
  } else {
    if (B.at(1) == 0) {
      ans = 0;
    } else {
      ans = S[0];
    }
  }
  for (int x = 0; x < (N); x++) {
    if (S[B.at(x + 1)] > 1) {
      long long sum = S[B.at(x + 1)] * (S[B.at(x + 1)] - 1) / 2;
      ans += sum;
      S[B.at(x + 1)] = 0;
    }
  }
  cout << ans << endl;
}
