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