#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int A[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  long long count = 0;
  long long sum = 0;
  long long s[N + 1];
  s[N] = 10000000010;
  int p[N];
  for (int i = 0; i < N; i++) {
    p[i] = 0;
  }
  for (int i = 0; i < N; i++) {
    sum = sum + A[i];
    s[i] = sum;
  }
  sort(s, s + N);
  int c = 0;
  for (int i = 0; i < N; i++) {
    if (s[i] == 0)
      c++;
    else if (s[i] == s[i + 1])
      c++;
    if (s[i] != s[i + 1] && c > 0) {
      count += c * (c + 1) / 2;
      c = 0;
    }
  }
  cout << count << "\n";
  return 0;
}
