#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long N;
  cin >> N;
  long long A[N];
  vector<long long> B(N + 1);
  B[0] = 0;
  map<long long, long long> p;
  p[0] = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    B[i + 1] = A[i] + B[i];
    p[B[i + 1]] = 0;
  }
  sort(B.begin(), B.end());
  for (int i = 0; i < N + 1; i++) {
    p[B[i]]++;
  }
  unique(B.begin(), B.end());
  int count = 0;
  for (int i = 0; i < p.size(); i++) {
    if (p[B[i]] >= 2) count += (p[B[i]]) * (p[B[i]] - 1) / 2;
  }
  cout << count << endl;
}
