#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  vector<ll> A;
  for (int i = 0; i < (int)(n); i++) cin >> A[i];
  vector<ll> s(n + 1, 0);
  for (int i = 0; i < (int)(n); i++) s[i + 1] = s[i] + A[i];
  map<ll, ll> hindo;
  for (int i = 0; i < (int)(n + 1); i++) {
    if (hindo.count(s[i]))
      hindo[s[i]]++;
    else
      hindo[s[i]] = 1;
  }
  ll sum = 0;
  for (auto p : hindo) {
    ll n = p.second;
    sum += n * (n - 1) / 2;
  }
  cout << sum << endl;
}
