#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> input;
  int N;
  int a;
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &a);
    input.push_back(a);
  }
  vector<int> forward_sum(N);
  vector<int> backward_sum(N);
  forward_sum[0] = input[0];
  for (int i = 1; i < N; i++) {
    forward_sum[i] = input[i] + forward_sum[i - 1];
  }
  forward_sum.push_back(0);
  int ans = 0;
  vector<int> sorted = vector<int>(forward_sum);
  std::sort(sorted.begin(), sorted.end());
  int prev = sorted[0];
  int count = 1;
  int last = 0;
  for (int i = 1; i < N + 1; i++) {
    if (prev == sorted[i]) {
      count++;
      continue;
    } else {
      ans += count * (count - 1) / 2;
      count = 1;
      prev = sorted[i];
      last = i;
    }
  }
  if (last != N) ans += count * (count - 1) / 2;
  printf("\n%d", ans);
}
