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