#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 2;
long long num[maxn];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &num[i]);
    if (i != 0) num[i] += num[i - 1];
  }
  sort(num, num + n);
  long long ans = 0;
  long long pair = 0;
  if (num[0] == 0) ans++;
  for (int i = 1; i < n; i++) {
    if (num[i] == 0) ans++;
    if (num[i] == num[i - 1]) pair++;
    if (num[i] != num[i - 1] && pair || i == n - 1 && pair) {
      ans += (pair + 1) * pair / 2;
      pair = 0;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
