#include <bits/stdc++.h>
using namespace std;
const int N = (int)(1e5 + 5);
long long n, ans;
long long a[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie();
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i], a[i] = a[i - 1] + a[i];
  sort(a + 1, a + n + 1);
  int c = 1;
  for (int i = 1; i <= n; i++) {
    if (i > 1) {
      if (a[i] == a[i - 1]) {
        c++;
      } else {
        ans += c * (c - 1) / 2;
        c = 1;
      }
    }
    if (a[i] == 0) ans++;
  }
  ans += c * (c - 1) / 2;
  cout << ans << endl;
  return 0;
}
