#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> as(n, 0);
  vector<long long> sums(n, 0);
  map<long long, long long> memo;
  long long ans = 0;
  memo[0] = 1;
  for (int i = 0; i < n; i++) {
    cin >> as[i];
    sums[i] = as[i];
    if (i != 0) {
      sums[i] += sums[i - 1];
    }
    if (as[i] == 0) {
      ans += 1;
    }
    if (memo.find(sums[i]) == memo.end()) {
      memo[sums[i]] = 1;
    } else {
      memo[sums[i]] += 1;
    }
  }
  for (auto i = memo.begin(); i != memo.end(); i++) {
    if (i->second == 1) continue;
    ans += i->second * (i->second - 1) / 2;
  }
  cout << ans << endl;
}
