#include <bits/stdc++.h>
using namespace std;
long long a[200002], dp[200002];
int main(void) {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%lld", a + i);
  long long sum;
  for (int i = n; i >= 1; i--) {
    sum = 0;
    for (int j = i; j >= 1; j--) {
      sum += a[j];
      if (sum == 0) {
        dp[j] = dp[i + 1] + 1;
        break;
      }
    }
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) ans += dp[i];
  return !printf("%lld\n", ans);
}
