#include <bits/stdc++.h>
using namespace std;
void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
const int N = 2e5 + 23;
int a[N];
unordered_map<int, int> h;
long long fact(long long n) {
  if (!n) return 1;
  return n * fact(n - 1);
}
void solve() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", a + i);
    a[i] += a[i - 1];
    ++h[a[i]];
  }
  ++h[0];
  long long ans = 0;
  for (const auto &e : h) {
    if (e.second < 2) continue;
    ans += (long long)(e.second - 1) * (e.second) / 2;
  }
  printf("\n%lld", ans);
}
int main() {
  init();
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
