#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n;
  cin >> n;
  vector<ll> a(n), b(n + 1);
  for (int i = 0; i < (int)(n); i++) {
    cin >> a[i];
    b[i + 1] = b[i] + a[i];
  }
  int ans = 0;
  map<ll, int> mp;
  for (int i = 0; i < (int)(n + 1); i++) {
    if (mp[b[i]] != 0) ans += mp[b[i]];
    mp[b[i]]++;
  }
  cout << ans << endl;
  return 0;
}
