#include <bits/stdc++.h>
using namespace std;
long long n, s1, a[200010], b[200010], sum[200010], ans;
inline int read() {
  int num = 0, flag = 1;
  char c = getchar();
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') flag = -1;
  for (; c >= '0' && c <= '9'; c = getchar())
    num = (num << 3) + (num << 1) + c - 48;
  return num * flag;
}
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) {
    b[i] = s1;
    s1 += i;
  }
  for (int i = 1; i <= n; ++i) {
    a[i] = read();
    sum[i] = sum[i - 1] + a[i];
    if (sum[i] == 0) ans++;
  }
  sort(sum + 1, sum + n + 1);
  for (int i = 1; i <= n; ++i) {
    long long s2 = 1;
    while (sum[i + 1] == sum[i]) {
      s2++;
      i++;
    }
    ans += b[s2];
  }
  printf("%lld\n", ans);
  return 0;
}
