#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int A[200000];
long long sumA[200001];
int main() {
  int N;
  cin >> N;
  for (int i = (int)(0), i_end = (int)(N); i < i_end; ++i) cin >> A[i];
  sumA[0] = A[0];
  for (int i = (int)(0), i_end = (int)(N); i < i_end; ++i) {
    sumA[i + 1] = sumA[i] + A[i + 1];
  }
  map<long long, int> m;
  for (int i = (int)(0), i_end = (int)(N + 1); i < i_end; ++i) m[sumA[i]]++;
  int count = 0;
  for (auto &x : m) {
    int y = x.second;
    count += y * (y - 1) / 2;
  }
  cout << (count - 1) << endl;
  return 0;
}
