#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> vec;
  long long int n, a;
  cin >> n;
  map<long long int, long long int> mp;
  for (int i = 0; i < n; i++) {
    cin >> a;
    vec.push_back(a);
    if (i == 0)
      vec[0] = a;
    else
      vec[i] = a + vec[i - 1];
    mp[vec[i]]++;
  }
  mp[0]++;
  long long int ans = 0;
  sort(vec.begin(), vec.end());
  vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    ans += (mp[*it] - 1) * mp[*it] / 2;
  }
  cout << ans << endl;
  return 0;
}
