#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 233;
int n;
long long a[maxn], sum[maxn];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%lld", &a[i]);
    sum[i] = sum[i - 1] + a[i];
  }
  sort(sum, sum + n + 1);
  long long ans = 0;
  for (int i = 0; i <= n; ++i) {
    int now = sum[i];
    int cnt = 0;
    while (sum[i] == now && i <= n) {
      cnt++;
      i++;
    }
    i--;
    ans += 1LL * cnt * (cnt - 1) / 2;
  }
  printf("%lld", ans);
  return 0;
}
