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