#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[200010];
  long long ans = 0;
  long long tmp;
  int plus;
  bool memo[200010] = {};
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  int size;
  for (int i = 0; i < n; i++) {
    if (!memo[i]) {
      tmp = 0;
      plus = 1;
      for (int j = i; j < n; j++) {
        tmp += a[j];
        if (tmp == 0) {
          ans += plus;
          plus++;
          memo[j + 1] = true;
        }
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}
