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