#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> S(N + 1, 0);
  S[0] = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    S[i + 1] = (S[i] + A[i]);
  }
  int c = 1;
  int ans = 0;
  int last = 0;
  sort(S.begin(), S.end());
  for (int i = 1; i <= N; i++) {
    if (last == S[i]) {
      c += 1;
    } else {
      ans += c * (c - 1) / 2;
      c = 1;
      last = S[i];
    }
  }
  ans += c * (c - 1) / 2;
  cout << ans << endl;
  return 0;
}
