#include <bits/stdc++.h>
using namespace std;
long long n, i, j, k, l, sum = 0, flag = 0, t, a[100005], ans = 0;
map<long long, long long> f;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> k;
    if (i) k += a[i - 1];
    a[i] = k;
    f[a[i]]++;
  }
  for (auto i : f) {
    ans += (i.second * (i.second - 1)) / 2;
  }
  cout << ans + f[0] << '\n';
  return 0;
}
