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