#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long double PI = acos(-1);
const long double EPS = 0.0000000001;
int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  long long cnt = 0;
  for (int i = 0; i < n - 1; i++) {
    long long tmp = 0;
    for (int j = i; j < n; j++) {
      tmp += a[j];
      if (tmp == 0) cnt += 1;
    }
  }
  cout << cnt << endl;
}
