#include <bits/stdc++.h>
using namespace std;
long long a[200005];
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    a[0] = 0;
    long long x;
    map<int, int> mp;
    for (int i = 1; i <= n; i++) {
      scanf("%lld", &x);
      a[i] = a[i - 1] + x;
      mp[a[i]]++;
    }
    long long sum = 0;
    for (int i = 0; i < n; i++) {
      if (mp[a[i]])
        for (int j = i + 1; j <= n; j++) {
          if (a[j] - a[i] == 0) {
            sum++;
          }
        }
    }
    printf("%lld\n", sum);
  }
  return 0;
}
