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