#include <bits/stdc++.h>
using namespace std;
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());
  int cnt = 1;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == s[i + 1])
      cnt++;
    else {
      ans += cnt * (cnt - 1) / 2;
      cnt = 1;
    }
  }
  if (cnt > 1) ans += cnt * (cnt - 1) / 2;
  cout << ans << '\n';
  return 0;
}
