#include <bits/stdc++.h>
using namespace std;
map<int, int> cnt;
int ps[100005];
int main() {
  int N, ans = 0;
  cin >> N;
  ps[0] = 0;
  cnt[0] = 1;
  for (int i = 1; i <= N; i++) {
    int num;
    cin >> num;
    ps[i] = num + ps[i - 1];
    cnt[ps[i]]++;
    if (cnt[ps[i]] > 1) {
      ans += cnt[ps[i]] - 1;
    }
  }
  cout << ans << endl;
}
