#include <bits/stdc++.h>
using namespace std;
constexpr long long INF = (1LL << 55);
int main() {
  int n;
  cin >> n;
  vector<long long> cum(n + 1, 0);
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    cum[i + 1] = cum[i] + a;
  }
  int res = 0;
  map<int, int> mp;
  for (int i = n; i > 0; i--) {
    res += mp[cum[i]];
    mp[cum[i]]++;
  }
  cout << res + mp[0] << endl;
  return 0;
}
