#include <bits/stdc++.h>
using namespace std;
long long GCD(long long a, long long b) {
  if (b == 0) return a;
  return GCD(b, a % b);
}
int main() {
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = (int)(0); i < (int)(N); ++i) cin >> A[i];
  map<long long, long long> m;
  long long sumA = 0;
  m[sumA] = 1;
  for (int i = (int)(0); i < (int)(N); ++i) {
    sumA += A[i];
    ++m[sumA];
  }
  long long res = 0;
  for (auto x : m) res += (x.second * x.second - 1) / 2;
  cout << res << endl;
}
