#include <bits/stdc++.h>
using namespace std;
int main() {
  int length;
  int* chain;
  int* s;
  cin >> length;
  chain = new int[length];
  s = new int[length + 1];
  for (int i = 0; i < length; i++) cin >> chain[i];
  s[0] = chain[0];
  for (int i = 1; i < length; i++) s[i] = s[i - 1] + chain[i];
  s[length] = 0;
  sort(s, s + length + 1);
  int count = 0;
  int answer = 0;
  int old = s[0];
  for (int i = 1; i < length + 1; i++) {
    if (old == s[i])
      count++;
    else {
      answer += count * (count - 1) / 2;
      count = 0;
    }
    old = s[i];
  }
  cout << count;
}
