#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];
  }
  int8_t bingo[200000];
  int count = 0;
  for (int i = 0; i <= N; i++) {
    count += bingo[presum[i] + 100000];
    bingo[presum[i] + 100000] += 1;
  }
  cout << count << endl;
}
