#include <bits/stdc++.h>
using namespace std;
int getsum(int k) { return k * (k - 1) / 2; }
int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  int num;
  long long qSum[200003] = {0};
  for (int i = 1; i <= n; ++i) {
    cin >> num;
    qSum[i] = qSum[i - 1] + num;
  }
  sort(qSum + 1, qSum + n + 1);
  long long sum = 0;
  long long k = 0;
  for (int i = 1; i <= n; ++i) {
    k = 1;
    for (; i < n; i++) {
      if (qSum[i] == 0) {
        sum++;
      }
      if (qSum[i] == qSum[i + 1]) {
        k++;
      } else {
        break;
      }
    }
    if (i == n && qSum[i] == 0) {
      sum++;
    }
    sum += getsum(k);
  }
  cout << sum << endl;
  return 0;
}
