#include <bits/stdc++.h>
using namespace std;
const int MxN = 200001;
const int MOD = 1e9 + 7;
int n;
vector<int> a(MxN);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  map<int, int> cnt;
  int sum = 0, ans = 0;
  cnt[0] = 1;
  for (int i = 0; i < n; ++i) {
    sum += a[i];
    if (cnt[sum] > 0) ans += cnt[sum];
    cnt[sum]++;
  }
  cout << ans;
  return 0;
}
