#include <bits/stdc++.h>
using namespace std;
int main(int, char**) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n, 0);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  long long cumsum = 0;
  map<long long, int> cumsumCounts;
  cumsumCounts[0] += 1;
  for (int i = n - 1; 0 < i; --i) {
    cumsum += a[i];
    cumsumCounts[cumsum] += 1;
  }
  int ans = 0;
  for (auto& cumsumItem : cumsumCounts) {
    int counts = cumsumItem.second;
    ans += counts * (counts - 1);
  }
  cout << ans << endl;
  return 0;
}
