#include <bits/stdc++.h>
using namespace std;
long long memo[200001] = {};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(9);
  int N, A[200000];
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];
  long long ans = 0;
  for (int i = N - 1; i >= 0; i--) {
    long long tmp = 0;
    for (int j = i; j < N; j++) {
      tmp += A[j];
      if (tmp == 0) {
        memo[i] = memo[j + 1] + 1;
        ans += memo[i];
      }
    }
  }
  cout << ans << endl;
  return 0;
}
