#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 62;
const int inf = 1 << 29;
int a[200005];
long long dp[200005];
int main() {
  int n;
  scanf("%d", &n);
  long long ans = 0;
  for (int i = (0); i < (n); ++i) scanf("%d", &a[i]);
  for (int i = n - 1; i >= 0; i--) {
    long long tem = 0;
    for (int j = i; j < n; j++) {
      tem += a[j];
      if (tem == 0) {
        if (j == n - 1) {
          ans++;
          dp[i] = 1;
        } else {
          ans += 1 + dp[j + 1];
          dp[i] = 1 + dp[j + 1];
          break;
        }
      }
    }
  }
  printf("%lld \n", ans);
  return 0;
}
