#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  map<int, int> ma = {};
  int n, ans = 0, m;
  int64_t a[200001] = {};
  cin >> n;
  ma[0]++;
  for (int i = 1; i <= n; i++) {
    cin >> m;
    a[i] = m + a[i - 1];
    ans += ma[a[i]];
    ma[a[i]]++;
  }
  cout << ans;
}
