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