#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, a, b[200005], ans;
  ans = 0;
  memset(b, 0, sizeof(b));
  scanf("%lld", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a);
    if (i != 0)
      b[i] = b[i - 1] + a;
    else
      b[i] = a;
  }
  sort(b, b + n);
  for (int i = 0; i < n; i++) {
    int k;
    k = 1;
    while (b[i] == b[i + 1]) {
      k = k + 1;
      i = i + 1;
    }
    k = k * (k - 1) / 2;
    ans += k;
  }
  for (int i = 0; i < n; i++)
    if (b[i] == 0) ans += 1;
  printf("%lld", ans);
}
