#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long n;
  cin >> n;
  vector<long long> v(n);
  for (long long i = 0; i < n; i++) {
    cin >> v[i];
  }
  vector<long long> s;
  s.push_back(0);
  for (long long i = 0; i < n; i++) {
    s.push_back(s[i] + v[i]);
  }
  s.push_back(99999999999);
  sort((s).begin(), (s).end());
  long long cnt = 1, ans = 0;
  for (long long i = 0; i < n + 1; i++) {
    if (s[i] == s[i + 1]) {
      cnt++;
    } else {
      ans += cnt * (cnt - 1) / 2;
      cnt = 1;
    }
  }
  cout << ans << endl;
}
