#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  int s[n];
  int ss = 0, count = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    ss += a[i];
    s[i] = ss;
    if (ss == 0) count++;
  }
  sort(s, s + n);
  int t = 0;
  for (int i = 0; i < n - 1; i++) {
    if (s[i] == s[i + 1]) {
      t++;
    } else {
      count += t * (t + 1) / 2;
      t = 0;
    }
    if (i == n - 2) count += t * (t + 1) / 2;
  }
  cout << count << endl;
  return 0;
}
