#include <bits/stdc++.h>
using namespace std;
uintmax_t combination(unsigned int n, unsigned int r) {
  if (r * 2 > n) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor = 1;
  for (unsigned int i = 1; i <= r; ++i) {
    dividend *= (n - i + 1);
    divisor *= i;
  }
  return dividend / divisor;
}
int main() {
  int n;
  int count = 0;
  cin >> n;
  vector<int> a(n);
  vector<int> second(n + 1);
  vector<int> b(10000000, 0);
  for (int i = 0; i < (int)(n); i++) {
    cin >> a[i];
    second[i + 1] = second[i];
    second[i + 1] += a[i];
  }
  for (int i = 0; i < (int)(n); i++) {
    b[second[i]]++;
  }
  for (int i = 0; i < (int)(10000000); i++) {
    if (b[i] != 0) {
      count += (int)combination(i, 2);
    }
  }
  cout << count << endl;
  return 0;
}
