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