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