#include <bits/stdc++.h>
using namespace std;
template <typename T>
bool chkmax(T &a, T b) {
  return a < b ? a = b, 1 : 0;
}
template <typename T>
bool chkmin(T &a, T b) {
  return a > b ? a = b, 1 : 0;
}
const int maxn = 2e5 + 1e2;
int n;
int val[maxn];
long long Ans;
map<int, int> cnt;
inline void file() {
  freopen("AGC023A.in", "r", stdin);
  freopen("AGC023A.out", "w", stdout);
}
inline int read() {
  int x = 0, p = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') p = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + (c - '0');
    c = getchar();
  }
  return x * p;
}
int main() {
  n = read();
  for (int i = (int)1; i <= (int)n; ++i) val[i] = read(), val[i] += val[i - 1];
  for (int i = (int)0; i <= (int)n; ++i) cnt[val[i]]++;
  for (int i = (int)0; i <= (int)n; ++i) {
    Ans += 1ll * cnt[val[i]] * (cnt[val[i]] - 1) / 2;
    cnt[val[i]] = 0;
  }
  printf("%lld\n", Ans);
  return 0;
}
