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