#include <bits/stdc++.h>
using namespace std;
long long n, s, a[200010], b[200010], sum[200010], ans;
long long min_ = 2e18, max_ = -2e18;
map<long long, long long> m;
vector<long long> v;
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] = s;
    s += i;
  }
  for (int i = 1; i <= n; ++i) {
    a[i] = read();
    sum[i] = sum[i - 1] + a[i];
    if (sum[i] == 0) ans++;
    m[sum[i]]++;
    min_ = min(min_, sum[i]);
    max_ = max(max_, sum[i]);
  }
  for (int i = min_; i <= max_; ++i)
    if (m[i] != 0 && m[i] != 1) v.push_back(m[i]);
  for (int i = 0; i < v.size(); ++i) ans += b[v[i]];
  printf("%lld\n", ans);
  return 0;
}
