#include <bits/stdc++.h>
using namespace std;
int main() {
  map<int, int> sum_l;
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < (int)(N); i++) cin >> A[i];
  long long sum = 0;
  for (int i = 0; i < (int)(N); i++) {
    sum += A[i];
    sum_l[sum]++;
  }
  long long ans = 0;
  for (auto itr = sum_l.begin(); itr != sum_l.end(); itr++) {
    ans += itr->second * (itr->second - 1) / 2;
    if (itr->first == 0) {
      ans += itr->second;
    }
  }
  cout << ans << endl;
}
