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