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