#include <bits/stdc++.h>
using namespace std;
long long N;
long long sum[200200];
map<long long, long long> mp;
signed main() {
  cin >> N;
  long long ans = 0;
  mp[0] = 1;
  for (long long i = 1; i <= N; i++) {
    cin >> sum[i];
    if (sum[i] == 0) ans++;
    sum[i] += sum[i - 1];
    ans += mp[sum[i]];
    mp[sum[i]]++;
  }
  cout << ans << endl;
  return 0;
}
