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