#include <bits/stdc++.h>
using namespace std;
long long int ans;
map<long long int, vector<long long int> > mp;
void findSubArrays(long long int arr[], long long int n) {
  long long int sum = 0;
  for (long long int i = 0; i < n; i++) {
    sum += arr[i];
    if (sum == 0) ans++;
    if (mp.find(sum) != mp.end()) {
      vector<long long int> vc = mp[sum];
      ans += vc.size();
    }
    mp[sum].push_back(i);
  }
}
long long int a[200005];
int main() {
  long long int i, j, k, n, m, z = 0, c = 0, t, x, y, l, r, mid;
  cin >> n;
  for (i = 0; i < n; i++) cin >> a[i];
  findSubArrays(a, n);
  cout << ans << endl;
  return 0;
}
