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