#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &num) {
  char c = getchar();
  T f = 1;
  num = 0;
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    num = (num << 3) + (num << 1) + (c ^ 48);
    c = getchar();
  }
  num *= f;
}
template <typename T>
void qwq(T x) {
  if (x > 9) qwq(x / 10);
  putchar(x % 10 + '0');
}
template <typename T>
void write(T x) {
  if (x < 0) {
    x = -x;
    putchar('-');
  }
  qwq(x);
  putchar('\n');
}
int co[200010];
long long pre[200010];
priority_queue<int> v;
int main() {
  int n;
  read(n);
  for (int i = 1; i <= n; i++) {
    read(co[i]);
    pre[i] = pre[i - 1] + co[i];
    v.push(pre[i]);
  }
  v.push(0);
  long long ans = 0;
  while (!v.empty()) {
    int nop = v.top();
    v.pop();
    int cnt = 1;
    while (!v.empty() && nop == v.top()) {
      cnt++;
      v.pop();
    }
    ans += 1ll * cnt * (cnt - 1) / 2;
  }
  write(ans);
  return 0;
}
