#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
int main() {
  int n;
  cin >> n;
  std::vector<ll> a(n);
  for (auto& i : a) std::cin >> i;
  ;
  ll res = 0;
  vector<ll> sum(n, 0);
  for (int i = 0; (i) < (int)(n); i++) {
    if (a[i] == 0) res++;
    if (i == 0)
      sum[i] = a[i];
    else
      sum[i] = sum[i - 1] + a[i];
  }
  map<ll, int> mp;
  for (int i = 0; (i) < (int)(n); i++) {
    mp[sum[i]]++;
  }
  for (auto m : mp) {
    if (m.first == 0) res += m.second;
    res += m.second * (m.second - 1) / 2;
  }
  cout << res << endl;
}
