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