#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (auto& a : A) cin >> a;
  for (int i = 1; i < N; ++i) {
    A[i] += A[i - 1];
  }
  int64_t ans = 0;
  map<int, int> m;
  m[0] = 1;
  for (int i = 0; i < N; ++i) {
    ans += m[A[i]];
    m[A[i]]++;
  }
  cout << ans << endl;
}
