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