#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  vector<int> sum(n + 1);
  sum[0] = 0;
  for (int i = 0; i < n; ++i) sum[i + 1] = sum[i] + a[i];
  sort(sum.begin(), sum.end());
  int ans = 0, cnt = 1;
  for (int i = 0; i <= n; ++i) {
    if (sum[i] == sum[i - 1])
      cnt++;
    else {
      ans += cnt * (cnt - 1) / 2;
      cnt = 1;
    }
  }
  ans += cnt * (cnt - 1) / 2;
  cout << ans << endl;
  return 0;
}
