#include <bits/stdc++.h>
using namespace std;
long long cmb2(int n) {
  long long a = 1LL, b = 1LL;
  for (int i = n; i >= 3; i--) a *= i;
  for (int i = n - 2; i >= 2; i--) b *= i;
  return a / b;
}
int main() {
  int n;
  cin >> n;
  vector<long long> s(n + 1);
  s[0] = 0;
  for (int i = 0; i < n; i++) {
    long long a;
    cin >> a;
    s[i + 1] = s[i] + a;
  }
  sort(s.begin(), s.end());
  long long ans = 0LL;
  int fl = 1;
  for (int i = 0; i < n; i++) {
    if (s[i] == s[i + 1])
      fl++;
    else {
      if (fl >= 2) ans += cmb2(fl);
      fl = 1;
    }
  }
  if (fl >= 2) ans += cmb2(fl);
  cout << ans << endl;
}
