#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[200005], sum[200005], i, j, cnt = 0, ans = 0, ans1 = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  for (i = 0; i < n; i++) {
    cnt += a[i];
    sum[i] = cnt;
  }
  sum[n] = 0;
  sort(sum, sum + n + 1);
  for (i = 1; i <= n; i++) {
    if (sum[i - 1] == sum[i])
      ans++;
    else {
      ans1 += ans * (1 + ans) / 2;
      ans = 0;
    }
  }
  ans1 += ans * (1 + ans) / 2;
  printf("%d\n", ans1);
}
