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