#include <bits/stdc++.h>
using namespace std;
int nc2(int n) { return n * (n - 1) / 2; }
int main() {
  int n;
  int num;
  int cnt = 0;
  int ans = 0;
  int ruiseki[200005];
  int a;
  scanf("%d", &n);
  fill(ruiseki, ruiseki + n + 1, 0);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a);
    ruiseki[i] = ruiseki[i - 1] + a;
  }
  sort(ruiseki, ruiseki + n + 1);
  ruiseki[n + 1] = 2 << 29;
  num = ruiseki[0];
  for (int i = 0; i <= n; i++) {
    cnt++;
    if (num != ruiseki[i + 1]) {
      ans += nc2(cnt);
      num = ruiseki[i + 1];
      cnt = 0;
    }
  }
  printf("%d\n", ans);
  return (0);
}
