#include <bits/stdc++.h>
using namespace std;
int CountDup(const vector<int64_t>& v) {
  int64_t prev = v[0];
  int ret = 0;
  int cnt = 1;
  for (int i = 1; i < static_cast<int>(v.size()); ++i) {
    if (prev == v[i]) {
      ++cnt;
    } else {
      if (cnt > 1) {
        ret += cnt * (cnt - 1) / 2;
      }
      cnt = 1;
    }
    prev = v[i];
  }
  if (cnt > 1) {
    ret += cnt * (cnt - 1) / 2;
  }
  return ret;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> A(N);
  int64_t sum = 0;
  vector<int64_t> cumsum(N + 1, 0);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
    sum += A[i];
    cumsum[i + 1] = sum;
  }
  sort(cumsum.begin(), cumsum.end());
  cout << CountDup(cumsum) << endl;
  return 0;
}
