#include <bits/stdc++.h>
using namespace std;
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, cs, ans = 0;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  map<int, int> mp;
  mp[0] = 1;
  cs = 0;
  for (int i = 0; i < n; i++) {
    cs += a[i];
    mp[cs]++;
  }
  for (auto i : mp) {
    ans += i.second * (i.second - 1) / 2;
  }
  cout << ans;
}
