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