#include <bits/stdc++.h>
using namespace std;
long long a[200010];
void solve() {
  int tmp2 = 0;
  map<long long, long long> mp;
  int n;
  cin >> n;
  cin >> a[0];
  if (a[0] == 0) tmp2++;
  mp[a[0]]++;
  for (int i = 1; i < n; i++) {
    cin >> a[i];
    a[i] += a[i - 1];
    if (a[i] == 0) tmp2++;
    mp[a[i]]++;
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    if (mp[i] != 0) {
      long long tmp = mp[i];
      ans += (tmp * (tmp - 1)) / 2;
    }
  }
  cout << ans + tmp2 << endl;
}
int main() {
  solve();
  return 0;
}
