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