#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 200000;
int N;
int A[MAX_N];
long long sums[MAX_N];
map<long long, long long> cmb;
int solve() {
  long long answer = 0;
  long long sum = 0;
  sums[0] = 0;
  for (int i = (int)(0); i < (int)(N); i++) {
    sum += A[i];
    sums[i] = sum;
  }
  cmb.clear();
  cmb[0] = 1;
  for (int i = (int)(0); i < (int)(N); i++) {
    long long key = sums[i];
    if (cmb.count(key) == 0) cmb[key] = 0;
    cmb[key]++;
  }
  for (map<long long, long long>::iterator it = cmb.begin(); it != cmb.end();
       ++it) {
    long long key = it->first;
    long long cnt = it->second;
    42;
    if (cnt <= 1) continue;
    answer += cnt * (cnt - 1) / 2;
  }
  return answer;
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  for (int i = (int)(0); i < (int)(N); i++) cin >> A[i];
  cout << solve() << "\n";
}
