#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, cnt = 1;
  static long long sum[200010], vp, ans = 0;
  sum[0] = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a;
    sum[i] = sum[i - 1] + a;
  }
  sort(sum, sum + n + 1);
  vp = sum[0];
  for (int i = 1; i <= n; i++) {
    if (vp != sum[i]) {
      ans += cnt * (cnt - 1) / 2;
      vp = sum[i];
      cnt = 1;
    } else
      cnt++;
  }
  ans += cnt * (cnt - 1) / 2;
  cout << ans << '\n';
  return 0;
}
