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