#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
int main() {
  int n, a;
  ull ans = 0LL;
  cin >> n;
  vector<int> s(n, 0);
  map<ull, int> mp;
  for (int i = 0; i < n; i++) {
    cin >> a;
    s[i] += a + (i ? s[i - 1] : 0);
    ++mp[s[i]];
  }
  for (auto el : mp) {
    if (el.first == 0) {
      ans += 1LL * el.second;
    }
    ans += 1LL * el.second * (el.second - 1) / 2;
  }
  cout << ans << "\n";
  return 0;
}
