#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int(i) = 0; (i) < (n); (i)++) cin >> a[i];
  vector<ll> prefix_sum(n + 1, 0);
  for (int(i) = 0; (i) < (n); (i)++) {
    prefix_sum[i + 1] = prefix_sum[i] + a[i];
  }
  unordered_map<ll, int> counter;
  for (auto h : prefix_sum) {
    counter[h]++;
  }
  ll ans = 0;
  for (auto p : counter) {
    ans += p.second * (p.second - 1) / 2;
  }
  cout << ans << endl;
}
