#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector<vector<ll>> dp;
ll comb(int n, int r) {
  if (n == r) return dp.at(n).at(r) = 1;
  if (r == 0) return dp.at(n).at(r) = 1;
  if (r == 1) return dp.at(n).at(r) = n;
  if (dp.at(r).at(n) != -1) return dp.at(r).at(n);
  return dp.at(r).at(n) = comb(n - 1, r) + comb(n - 1, r - 1);
}
int main() {
  int N;
  cin >> N;
  dp = vector<vector<ll>>(N, vector<ll>(N, -1));
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  vector<int> cs(N + 1, 0);
  for (int i = 0; i < N; i++) cs.at(i + 1) = cs.at(i) + A.at(i);
  sort(cs.begin(), cs.end(), [](int l, int r) -> bool { return l > r; });
  cs.erase(find(cs.begin(), cs.end(), 0));
  int res = count(cs.begin(), cs.end(), 0);
  int prev, cnt = 0;
  for (int i = 0; i < N; i++) {
    if (i == 0) {
      prev = cs.at(i);
      cnt = 1;
    } else if (cs.at(i) == prev) {
      cnt++;
      if (i == N - 1) {
        res += comb(cnt, 2);
      }
    } else {
      if (cnt > 1) res += comb(cnt, 2);
      prev = cs.at(i);
      cnt = 1;
    }
  }
  cout << res << endl;
}
