#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll nC2(int n) { return n * (n - 1) / 2; }
int main(void) {
  ll n;
  cin >> n;
  vector<ll> a(n + 1, 0);
  for (int i = 1; i <= (n); ++i) cin >> a[i];
  for (int i = 0; i < (n); ++i) a[i + 1] = a[i + 1] + a[i];
  sort(a.begin(), a.end());
  ll ans = 0, c = 1;
  a.push_back(0);
  for (int i = 0; i < (n + 1); ++i) {
    if (a[i] == a[i + 1])
      c++;
    else {
      ans += nC2(c);
      c = 1;
    }
  }
  cout << ans << endl;
  return 0;
}
