#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n;
  cin >> n;
  vector<long long> a(n + 1, 0);
  for (long long i = 1; i <= n; i++) cin >> a[i];
  for (long long i = 1; i < n - 1; i++) a[i + 1] += a[i];
  map<long long, long long> cnt;
  for (auto&& w : a) cnt[w]++;
  long long sum = 0;
  for (auto&& w : cnt) sum += w.second * (w.second - 1) / 2;
  cout << sum << endl;
}
