#include <bits/stdc++.h>
using namespace std;
const int N = 2 * 1e5;
long long ara[N + 3];
long long cum[N + 3];
int bin_srch_l(int key, int posl, int posh) {
  int hi = posh, lo = posl + 1, mid, ans = -1;
  while (hi >= lo) {
    mid = (hi + lo) / 2;
    if (cum[mid] == key) {
      ans = mid;
      hi = mid - 1;
    } else if (cum[mid] < key) {
      lo = mid + 1;
    } else
      hi = mid - 1;
  }
  return ans;
}
int bin_srch_h(int key, int posl, int posh) {
  int hi = posh, lo = posl + 1, mid, ans = -1;
  while (hi >= lo) {
    mid = (hi + lo) / 2;
    if (cum[mid] == key) {
      ans = mid;
      lo = mid + 1;
    } else if (cum[mid] < key) {
      lo = mid + 1;
    } else
      hi = mid - 1;
  }
  return ans;
}
int main() {
  long long n;
  scanf("%lld", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &ara[i]);
  for (int i = 1; i <= n; i++) cum[i] = cum[i - 1] + ara[i];
  sort(cum + 1, cum + n + 1);
  int cnt = 0;
  for (int i = 1; i < n; i++) {
    int x = bin_srch_l(cum[i], i, n + 1);
    int y = bin_srch_h(cum[i], i, n + 1);
    if (x != -1 or y != -1) cnt += (y - x + 1);
    if (cum[i] == 0) cnt++;
  }
  cout << cnt << endl;
}
