#include <bits/stdc++.h>
using namespace std;
int main() {
  long n;
  cin >> n;
  vector<long long> wa(n);
  cin >> wa[0];
  long ans = 0;
  for (int i = (1); i < (int)(n); i++) {
    long a;
    cin >> a;
    wa[i] = wa[i - 1] + a;
    if (wa[i] == 0) ans++;
    for (int j = (0); j < (int)(i - 1); j++) {
      if (wa[i] - wa[j] == 0) ans++;
    }
  }
  cout << (ans) << endl;
  return 0;
}
