#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  map<long long, int> mp;
  long long sum = 0;
  mp[sum]++;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    sum += a;
    if (mp.count(sum)) ans += mp[sum];
    mp[sum]++;
  }
  cout << ans << '\n';
  return 0;
}
