#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, a;
  cin >> n;
  int s[210000];
  s[0] = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    s[i + 1] = s[i] + a;
  }
  sort(s, s + n + 1);
  int ans = 0;
  int i = 0;
  while (i < n + 1) {
    int cnt = 1;
    while (i + 1 < n + 1 && s[i] == s[i + 1]) {
      ++i;
      ++cnt;
    }
    if (cnt >= 2) ans += cnt * (cnt - 1) / 2;
  }
  cout << ans << '\n';
  return 0;
}
