#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  vector<long long> cum_sum(N + 1);
  for (int i = 0; i < N; i++) {
    cum_sum[i + 1] = cum_sum[i] + A[i];
  }
  unordered_map<int, int> hash;
  for (long long n : cum_sum) hash[n]++;
  long long res = 0;
  for (pair<int, int> p : hash) {
    res += (long long)p.second * (p.second - 1) / 2;
  }
  cout << res << endl;
  return 0;
}
