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