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