#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  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);
  int temp = 0;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (i != 0 && b[i - 1] == b[i]) {
      temp++;
    } else {
      ans += temp * (temp + 1) / 2;
      temp = 0;
    }
  }
  ans += temp * (temp + 1) / 2;
  temp = 0;
  for (int i = 0; i < n; i++) {
    if (b[i] == 0) {
      ans++;
    }
  }
  cout << ans << endl;
}
