#include <bits/stdc++.h>
using namespace std;
const int MaxN = 1e5;
long long sum[MaxN + 5];
int main() {
  long long n, piu, ans;
  while (~scanf("%lld", &n)) {
    sum[0] = 0;
    for (long long i = 1; i <= n; i++) {
      scanf("%lld", &piu);
      sum[i] = sum[i - 1] + piu;
    }
    sort(sum, sum + 1 + n);
    piu = 1;
    ans = 0;
    for (long long i = 1; i <= n; i++) {
      if (sum[i] != sum[i - 1]) {
        ans += piu * (piu - 1) / 2;
        piu = 1;
      } else
        piu++;
    }
    ans += piu * (piu - 1) / 2;
    printf("%lld\n", ans);
  }
  return 0;
}
