#include <bits/stdc++.h>
using namespace std;
long long Con(long long a) { return a * (a - 1) / 2; }
int main() {
  int N;
  if (N == 1) {
    cout << 0 << endl;
    return 0;
  }
  scanf("%d", &N);
  vector<long long> A(N);
  vector<long long> B(N + 1, 0);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
    B[i + 1] = B[i] + A[i];
  }
  sort(B.begin(), B.end());
  B.push_back(0);
  long long ans = 0;
  long long now = B[0];
  int cnt = 1;
  for (int i = 1; i <= N + 1; i++) {
    if (B[i] == now) {
      cnt++;
    } else {
      if (cnt > 1) {
        ans += Con(cnt);
      }
      now = B[i];
      cnt = 1;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
