#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, ans = 0, c = 1;
  cin >> n;
  vector<int> a(n), cs(n + 1);
  cs[0] = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    cs[i + 1] = cs[i] + a[i];
  }
  sort(cs.begin(), cs.end());
  for (int i = 1; i < n + 1; i++) {
    if (cs[i] == cs[i - 1]) {
      c++;
    } else {
      ans += c * (c - 1) / 2;
      c = 1;
    }
  }
  ans += c * (c - 1) / 2;
  cout << ans;
}
