#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  long long int a[n];
  for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
  priority_queue<long long int> q1;
  priority_queue<long long int> q2;
  long long int s = 0;
  map<long long int, long long int> timemap;
  timemap[0] = 0;
  for (int i = 0; i < n; i++) {
    s += a[i];
    if (timemap.find(-s) != timemap.end())
      timemap[-s]++;
    else
      timemap[-s] = 0;
  }
  s = 0;
  int ans = 0;
  ans += timemap[0];
  for (int i = 0; i < n; i++) {
    s += a[i];
    ans += timemap[-s];
  }
  printf("%d\n", (ans) / 2);
}
