#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e5 + 1;
int N;
long long A[MAX_N];
long long solve() {
  unordered_map<long long, long long> M;
  long long res = 0, sum = 0;
  M[0] = 1;
  for (int i = 0; i < (N); ++i) {
    sum += A[i];
    if (M.count(sum)) res += M[sum];
    M[sum]++;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  for (int i = 0; i < (N); ++i) cin >> A[i];
  cout << solve() << endl;
  return 0;
}
