#include <bits/stdc++.h>
using namespace std;
int A[100005];
long long psum[100005];
map<long long, int> mp;
int main() {
  int n;
  cin >> n;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    cin >> A[i];
    psum[i] = psum[i - 1] + 1LL * A[i];
    if (psum[i] == 0) ans++;
  }
  for (int i = 1; i <= n; i++) {
    mp[psum[i]]++;
  }
  for (auto it = mp.begin(); it != mp.end(); it++) {
    int val = it->second;
    ans += 1LL * val * (val - 1) / 2;
  }
  cout << ans;
}
