#include <bits/stdc++.h>
using namespace std;
int n;
long long a;
long long imos[200010];
map<long long, int> mp;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = (0); i < (n); ++i) {
    cin >> a;
    imos[i + 1] = imos[i] + a;
  }
  for (int i = (0); i < (n + 1); ++i) {
    mp[imos[i]]++;
  }
  long long ans = 0;
  for (auto x : mp) {
    if (x.second >= 2) {
      ans += x.second * (x.second - 1) / 2;
    }
  }
  cout << ans << endl;
  return 0;
}
