#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  long long sum[211111];
  int i, j;
  cin >> N;
  sum[0] = 0;
  for (i = 1; i <= N; i++) {
    long long A;
    cin >> A;
    sum[i] += sum[i - 1] + A;
  }
  sort(sum, sum + N + 1);
  i = 0;
  j = 0;
  int count = 0;
  while (i <= N) {
    while (sum[i] == sum[j] && j <= N) j++;
    int n = j - i;
    count += n * (n - 1) / 2;
    i = j;
  }
  cout << count << endl;
  return 0;
}
