#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> a(n + 1);
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  map<long long, long long> cnt;
  long long sum = 0;
  for (int i = 0; i <= n; ++i) {
    sum += a[i];
    ++cnt[sum];
  }
  long long ans = 0;
  for (auto [val, c] : cnt) {
    ans += c * (c - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
