#include <bits/stdc++.h>
using namespace std;
long long nC2(long long n) { return (n * (n - 1)) / 2; }
int main() {
  int N;
  cin >> N;
  vector<long long> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  vector<long long> sum(N);
  sum.at(0) = a.at(0);
  for (int i = 1; i < N; i++) {
    sum.at(i) = sum.at(i - 1) + a.at(i);
  }
  map<int, int> ans;
  vector<int> ele(0);
  long long count = 0;
  for (auto i : sum) {
    if (ans.count(i)) {
      ans[i]++;
      if (i == 0) {
        count++;
      }
    } else {
      ans[i] = 1;
      ele.push_back(i);
      if (i == 0) {
        count++;
      }
    }
  }
  for (auto i : ele) {
    if (ans[i] >= 2) {
      count += nC2(ans[i]);
    }
  }
  cout << count << endl;
}
