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