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