#include <bits/stdc++.h>
using namespace std;
vector<long long> count(vector<long long> v) {
  vector<long long> ans;
  v.push_back(0);
  long long cnt = 0;
  for (long long i = 0; i < v.size() - 1; i++) {
    cnt++;
    if (v.at(i) != v.at(i + 1)) {
      ans.push_back(cnt);
      cnt = 0;
    }
  }
  return ans;
}
signed main() {
  long long n;
  cin >> n;
  vector<long long> a(n), aa(n + 1, 0);
  long long sum = 0;
  for (long long i = 0; i < n; i++) {
    cin >> a.at(i);
    sum += a.at(i);
    aa.at(i + 1) = sum;
  }
  sort(aa.begin(), aa.end());
  vector<long long> aaa = count(aa);
  long long ans = 0;
  for (long long i = 0; i < aaa.size(); i++) {
    ans += aaa.at(i) * (aaa.at(i) - 1) / 2;
  }
  cout << ans << endl;
}
