#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int((i)) = (0); ((i)) < ((n)); ((i))++) cin >> a[i];
  int asum[n + 1];
  asum[0] = 0;
  map<long long, long long> mp;
  mp[0]++;
  for (int((i)) = (0); ((i)) < ((n)); ((i))++) {
    asum[i + 1] = asum[i] + a[i];
    mp[asum[i + 1]]++;
  }
  long long ans = 0;
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    long long k = itr->second;
    ans += k * (k - 1) / 2;
  }
  cout << ans << endl;
}
