#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N + 1);
  vector<long long> S(N + 1);
  map<long long, int> counter;
  S.at(0) = 0;
  counter[0]++;
  for (int i = 1; i <= N; i++) {
    cin >> A.at(i);
    S.at(i) = S.at(i - 1) + A.at(i);
    counter[S.at(i)]++;
  }
  long long ans = 0;
  for (auto p : counter) {
    auto v = p.second;
    if (v != 0) ans += v * (v - 1) / 2;
  }
  cout << ans << endl;
}
