#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int a[200000];
int b[200000];
int main() {
  ll n;
  cin >> n;
  for (ll i = 0; i < (int)(n); i++) {
    cin >> a[i];
  }
  for (ll i = 0; i < (int)(n); i++) {
    if (i) b[i] += b[i - 1];
    b[i] += a[i];
  }
  map<ll, ll> mp;
  for (ll i = 0; i < (int)(n); i++) {
    mp[b[i]]++;
  }
  ll sum = 0;
  for (auto at : mp) {
    ll tm = at.first == 0 ? at.second : at.second - 1;
    for (ll i = 1; i <= (int)(tm); i++) {
      sum += i;
    }
  }
  cout << sum << endl;
}
