#include <bits/stdc++.h>
using namespace std;
int n, a[200010], ans;
long long sum[200010], Hsum[200010];
map<int, long long> mp;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    sum[i] = sum[i - 1] + a[i];
  }
  for (int i = n; i > 1; i--) {
    Hsum[i] = Hsum[i + 1] + a[i];
    mp[Hsum[i]]++;
  }
  for (int i = 0; i < n; i++) {
    ans += mp[sum[n] - sum[i]];
    if (sum[n] - sum[i] == 0) ans++;
    if (i < n - 1) mp[Hsum[i + 2]]--;
  }
  printf("%d", ans);
  return 0;
}
