#include <bits/stdc++.h>
const bool DEBUG = false;
using namespace std;
const long long maxn = 2e5 + 5;
const long long INF = 1e18 + 1;
const long long M = 1e9 + 7;
const int lg = 21;
map<int, long long> mp;
int n, a[maxn];
long long dp[maxn];
long long cnt(int l, int r) {
  if (l == 0) return dp[r];
  return dp[r] - dp[l - 1];
}
long long solve(int l, int r) {
  if (r - l == 0) return 0;
  int mid = l + r >> 1;
  long long ans = solve(l, mid) + solve(mid + 1, r);
  mp.clear();
  for (int i = l; i <= mid; i++) mp[cnt(i, mid)]++;
  for (int i = mid + 1; i <= r; i++) ans += mp[-cnt(mid + 1, i)];
  return ans;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  dp[0] = a[0];
  for (int i = 1; i < n; i++) dp[i] = dp[i - 1] + a[i];
  cout << solve(0, n - 1) << endl;
  return 0;
}
