#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int array[N];
  for (int i = 0; i < N; i++) {
    cin >> array[i];
  }
  long long int presum[N + 1];
  presum[0] = 0;
  for (int i = 0; i < N; i++) {
    presum[i + 1] = presum[i] + array[i];
  }
  sort(presum, presum + N + 1);
  int now = presum[0], count = 0, sum = 0;
  for (int i = 1; i < N + 1; i++) {
    if (presum[i] == now) {
      count += 1;
    } else {
      count = 0;
      now = presum[i];
    }
    sum += count;
  }
  cout << sum << endl;
}
