#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<long long> s;
  long long tmp;
  s.resize(N + 1);
  cin >> s[0];
  int sum = 0;
  for (int i = 1; i < N; i++) {
    scanf("%lld", &tmp);
    s[i] = s[i - 1] + tmp;
  }
  s[N] = 0;
  sort(s.begin(), s.end());
  int sign = 0, count = 1;
  for (int i = 1; i < N + 1; i++) {
    if (s[i] == s[sign]) {
      count++;
      if (i == N) {
        sum += (count * (count - 1)) / 2;
        if (s[sign] == 0) sum += count;
      }
    } else {
      sum += (count * (count - 1)) / 2;
      count = 1;
      sign = i;
    }
  }
  cout << sum << "\n";
  return 0;
}
