#include <bits/stdc++.h>
using namespace std;
int N;
int A[201000];
long long sum = 0l;
map<int, long long> M;
int main() {
  cin >> N;
  for (int i = 1; i <= N; ++i) {
    cin >> A[i];
    A[i] += A[i - 1];
    if (M.find(A[i]) == M.end()) {
      M.insert(make_pair(A[i], 1l));
    } else {
      ++M[A[i]];
    }
  }
  for (auto i = M.begin(); i != M.end(); ++i) {
    if (i->first != 0) {
      sum += (i->second) * (i->second - 1) / 2;
    } else {
      sum += (i->second) * (i->second + 1) / 2;
    }
  }
  cout << sum << endl;
}
