#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> a(N, 0);
  for (int i = 0; i < N; ++i) cin >> a[i];
  vector<int> s(N + 1, 0);
  for (int i = 0; i < N; ++i) s[i + 1] = s[i] + a[i];
  std::sort(s.begin(), s.end());
  int sum = 1;
  int count = 0;
  int res = 0;
  for (int i = 0; i < N + 1; ++i) {
    if (i == 0) continue;
    if (s[i] == s[i - 1]) {
      count++;
      res += count;
    } else
      count = 0;
  }
  cout << res << endl;
}
