#include <bits/stdc++.h>
using namespace std;
template <class T, template <class, class> class C, class charT = char>
void vdump(const C<T, allocator<T>> &v, const charT *delimiter = ", ",
           ostream &stream = cout) {
  copy(v.begin(), v.end(), ostream_iterator<T>(stream, delimiter));
  stream << endl;
}
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<long long> as(n);
  for (auto &a : as) {
    cin >> a;
  }
  vector<long long> sum(n + 1, 0);
  for (int i = (int)(0); i < (int)(n); i++) {
    sum[i + 1] = sum[i] + as[i];
  }
  sort(sum.begin() + 1, sum.end());
  long long count = 0;
  long long same = 1;
  long long prev = 0;
  for (int i = (int)(1); i < (int)(n + 1); i++) {
    if (sum[i] == prev) {
      same++;
    } else {
      count += same * (same - 1) / 2;
      same = 1;
      prev = sum[i];
    }
  }
  count += same * (same - 1) / 2;
  cout << count << endl;
  return 0;
}
