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