#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, count, tmp, tmp2;
  int *A;
  vector<int> sum;
  cin >> n;
  A = new int[n];
  count = 0;
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  tmp = 0;
  for (int i = 0; i < n; i++) {
    tmp += A[i];
    sum.push_back(tmp);
  }
  sort(sum.begin(), sum.end());
  sum.push_back(sum[n - 1] + 1);
  tmp = 0;
  tmp2 = 0;
  count = 0;
  for (int i = 0; i < n + 1; i++) {
    if (tmp == sum[i]) {
      tmp2++;
    } else {
      count += tmp2 * (tmp2 + 1) / 2;
      tmp = sum[i];
      tmp2 = 0;
    }
  }
  cout << count << endl;
  return 0;
}
