#include <bits/stdc++.h>
using namespace std;
const int nmax = 2e5 + 10;
const int INF = 0x3f3f3f3f;
map<long long, long long> mpall;
map<long long, long long> mpfront;
int n;
long long a[nmax];
long long prefix[nmax];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%lld", &a[i]);
    if (i == 1)
      prefix[i] = a[i];
    else {
      prefix[i] = prefix[i - 1] + a[i];
      mpall[prefix[i]]++;
    }
  }
  long long sum = 0;
  int cnt = 0;
  for (int i = 1; i <= n; ++i) {
    cnt += mpall[sum] - mpfront[sum];
    if (i != 1) mpfront[prefix[i]]++;
    sum += a[i];
  }
  printf("%d\n", cnt);
  return 0;
}
