#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
int n;
long long a[100005];
map<long long, int> mp;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long ans = 0;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    sum += a[i];
    if (sum == 0) ans++;
    if (mp.find(sum) != mp.end()) {
      ans += mp[sum];
      mp[sum]++;
    } else {
      mp[sum] = 1;
    }
  }
  cout << ans << endl;
  return 0;
}
