#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[200010];
  long long sum[200010] = {0};
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sum[0] = a[0];
  for (int i = 1; i < n; i++) {
    sum[i] = sum[i - 1] + a[i];
  }
  sort(sum, sum + n);
  int ans = 0, cnt = 0;
  for (int i = 0; i < n; i++) {
    if (sum[i] == 0) cnt++;
  }
  ans += (cnt * (cnt + 1)) / 2;
  cnt = 0;
  int tmp = -2;
  for (int i = 0; i < n - 1; i++) {
    if (sum[i] == sum[i + 1]) {
      if (sum[i] != 0) {
        cnt++;
        tmp = i;
        if (i == n - 2) ans += (cnt * (cnt + 1)) / 2;
      }
    } else if (tmp == i - 1) {
      ans += (cnt * (cnt + 1)) / 2;
      cnt = 0;
    }
  }
  cout << ans << endl;
  return 0;
}
