#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
std::vector<std::vector<long long>> comb(int n, int r) {
  std::vector<std::vector<long long>> v(n + 1,
                                        std::vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v;
}
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = (0), i_end_ = (n); i < i_end_; i++) {
    cin >> a[i];
  }
  int ans = 0;
  vector<int> s(n + 1);
  for (int i = (0), i_end_ = (n); i < i_end_; i++) {
    s[i + 1] = s[i] + a[i];
  }
  sort((s).begin(), (s).end());
  int pre = 0, count = 0;
  vector<std::vector<lint>> v(n + 1, vector<lint>(n + 1, 0));
  v = comb(n + 1, n + 1);
  for (int i = (0), i_end_ = (n + 1); i < i_end_; i++) {
    int c = s[i];
    if (i == 0) {
      pre = c;
    }
    if (pre == c) {
      count += 1;
    } else {
      if (count != 1) {
        ans += count * (count - 1) / 2;
      }
      count = 1;
    }
    pre = c;
  }
  if (count != 1) {
    ans += count * (count - 1) / 2;
  }
  cout << ans << "\n";
  return 0;
}
