#include <bits/stdc++.h>
using namespace std;
long long INFl = 1e+18 + 1;
int INF = 1e+9 + 1;
int main() {
  long long N, A[200001], Asum[200001] = {0};
  long long toori = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 1; i <= N; i++) {
    Asum[i] = Asum[i - 1] + A[i - 1];
  }
  sort(Asum, Asum + N + 1);
  int nownum = Asum[0];
  long long count = 1;
  for (int i = 1; i <= N; i++) {
    if (Asum[i] == nownum) {
      count++;
    } else {
      nownum = Asum[i];
      toori += (long long)count * (count - 1) / 2;
      count = 1;
    }
  }
  toori += count * (count - 1) / 2;
  cout << toori << endl;
  return 0;
}
