#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<long long>;
int main() {
  ll n;
  cin >> n;
  vll a(n);
  vll b(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ll sum = a[i];
    for (ll j = i + 1; j < n; j++) {
      sum += a[j];
      if (sum == 0) {
        ans += 1 + b[i];
        if (j < n - 1) b[j + 1] += 1 + b[i];
        break;
      }
    }
  }
  cout << ans << endl;
}
