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