#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline long long read1() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
using namespace std;
int n;
long long a[200010], sum[200010], ans;
map<int, int> m;
int main() {
  n = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + a[i];
  m[0]++;
  for (int i = 1; i <= n; i++) m[sum[i]]++;
  for (int i = 1; i <= n; i++)
    if (m[sum[i]] > 1) {
      ans += 1ll * m[sum[i]] * (m[sum[i]] - 1);
      m[sum[i]] = 1;
    }
  cout << ans / 2;
  return 0;
}
