#include <bits/stdc++.h>
using namespace std;
int A[200000];
int prefix[200000];
int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  prefix[0] = A[0];
  for (int i = 1; i < N; ++i) {
    prefix[i] = prefix[i - 1] + A[i];
  }
  map<int, int> m;
  for (int i = 0; i < N; ++i) {
    m[prefix[i]]++;
  }
  int num = 0;
  for (const auto &p : m) {
    if (p.second >= 2) {
      num += p.second * (p.second - 1) / 2;
    }
    if (p.first == 0) {
      num += p.second;
    }
  }
  cout << num << endl;
  return 0;
}
