#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
long long a[maxn];
int n, b[maxn];
int main() {
  while (~scanf("%d", &n)) {
    for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
    for (int i = 1; i <= n; i++) a[i] += a[i - 1];
    long long sum = 0;
    for (int i = 1; i <= n; i++)
      if (a[i] != 0) sum++;
    sort(a + 1, a + n + 1);
    int length = 1, id = 1;
    memset(b, 0, sizeof(b));
    b[length] = 1;
    while (id < n) {
      if (a[id] != a[id + 1])
        length++, b[length] = 1;
      else
        b[length]++;
      id++;
    }
    for (int i = 1; i <= length; i++) sum += 1LL * (b[i] - 1) * b[i] / 2;
    printf("%lld\n", sum);
  }
  return 0;
}
