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