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