#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n), s(n + 1, 0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    s[i + 1] = s[i] + a[i];
  }
  sort(s.begin(), s.end());
  int sum = 0, e = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == s[i + 1]) {
      e++;
    } else {
      sum += e * (e + 1) / 2;
      e = 0;
    }
  }
  sum += e * (e + 1) / 2;
  cout << sum << endl;
}
