#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
  int n, in;
  ll comb(ll a, int b);
  cin >> n;
  vector<ll> add(n, 0);
  map<ll, ll> m;
  m[0]++;
  for (int i = 0; i < (int)(n); i++) {
    cin >> in;
    add.at(i) = in;
    if (i != 0) add.at(i) += add.at(i - 1);
    m[add.at(i)]++;
  }
  ll ans = 0;
  for (auto p : m) {
    if (p.second > 1) {
      ans += comb(p.second, 2);
    }
  }
  cout << ans << endl;
  return 0;
}
ll comb(ll a, int b) {
  ll fac(ll a);
  return fac(a) / fac(b) / fac(a - b);
}
ll fac(ll a) {
  ll ans = 1;
  for (int i = 1; i <= a; i++) {
    ans *= i;
  }
  return ans;
}
