#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int recorder[N];
  for (int i = 0; i < N; ++i) {
    cin >> recorder[i];
  }
  long long int cumul[N + 1];
  cumul[0] = 0;
  for (int i = 0; i < N; ++i) {
    cumul[i + 1] = cumul[i] + recorder[i];
  }
  unordered_map<long long int, int> cntmap;
  for (auto A : cumul) {
    if (cntmap.count(A) == 0) {
      cntmap[A] = 1;
    } else {
      ++cntmap[A];
    }
  }
  long long int ans = 0;
  for (auto kv : cntmap) {
    ans += kv.second * (kv.second - 1) / 2;
  }
  cout << ans << endl;
}
