#include <bits/stdc++.h>
using namespace std;
const long long INF = 10e16;
const int maxN = 200010;
long long a[maxN];
long long b[maxN];
map<long long, int> k;
int main() {
  int n;
  int ans = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  b[1] = a[1];
  for (int i = 2; i <= n; i++) {
    b[i] = b[i - 1] + a[i];
  }
  k[0] = 1;
  for (int i = 1; i <= n; i++) {
    ans += k[b[i]];
    k[b[i]]++;
  }
  printf("%d\n", ans);
  return 0;
}
