#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
long long n, a[maxn], s;
map<long long, int> mp;
long long re;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  mp[0]++;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    s += a[i];
    re += mp[s];
    mp[s]++;
  }
  cout << re;
  return 0;
}
