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