#include <bits/stdc++.h>
using namespace std;
int main() {
  map<long long, int> mp;
  int t;
  cin >> t;
  long long tmp = 0, ans = 0;
  mp[0] = 1;
  while (t--) {
    long long n;
    cin >> n;
    tmp += n;
    if (tmp == 0)
      ans += (mp[0]++) + 1;
    else
      ans += mp[tmp]++;
  }
  cout << ans << endl;
  return 0;
}
