#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 2e5 + 10;
long long n, a[MAXN], prs[MAXN], ans;
map<long long, long long> mpp;
int32_t main() {
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> a[i];
  for (long long i = 1; i <= n; i++) prs[i] = prs[i - 1] + a[i];
  for (long long i = 0; i <= n; i++) mpp[prs[i]]++;
  for (auto it : mpp)
    if (it.second >= 2) ans += it.second * (it.second - 1) / 2;
  return cout << ans - 1 << endl, 0;
}
