import sys
def get_majority_element(a, left, right):
if left == right:
return -1
if left + 1 == right:
return a[left]
left_m = get_majority_element(a, left, (left + right - 1)//2 + 1)
right_m = get_majority_element(a, (left + right - 1)//2 + 1, right)
left_count = 0
for i in range(left, right):
if a[i] == left_m:
left_count += 1
if left_count > (right-left)//2:
return left_m
right_count = 0
for i in range(left, right):
if a[i] == right_m:
right_count += 1
if right_count > (right-left)//2:
return right_m
return -1
if __name__ == '__main__':
input = sys.stdin.read()
n, *a = list(map(int, input.split()))
if get_majority_element(a, 0, n) != -1:
print(1)
else:
print(0)
aW1wb3J0IHN5cwoKZGVmIGdldF9tYWpvcml0eV9lbGVtZW50KGEsIGxlZnQsIHJpZ2h0KToKICAgIGlmIGxlZnQgPT0gcmlnaHQ6CiAgICAgICAgcmV0dXJuIC0xCiAgICBpZiBsZWZ0ICsgMSA9PSByaWdodDoKICAgICAgICByZXR1cm4gYVtsZWZ0XQoKICAgIGxlZnRfbSA9IGdldF9tYWpvcml0eV9lbGVtZW50KGEsIGxlZnQsIChsZWZ0ICsgcmlnaHQgLSAxKS8vMiArIDEpCiAgICByaWdodF9tID0gZ2V0X21ham9yaXR5X2VsZW1lbnQoYSwgKGxlZnQgKyByaWdodCAtIDEpLy8yICsgMSwgcmlnaHQpCiAgICBsZWZ0X2NvdW50ID0gMAogICAgZm9yIGkgaW4gcmFuZ2UobGVmdCwgcmlnaHQpOgogICAgICAgIGlmIGFbaV0gPT0gbGVmdF9tOgogICAgICAgICAgICBsZWZ0X2NvdW50ICs9IDEKICAgIGlmIGxlZnRfY291bnQgPiAocmlnaHQtbGVmdCkvLzI6CiAgICAgICAgcmV0dXJuIGxlZnRfbQoKICAgIHJpZ2h0X2NvdW50ID0gMAogICAgZm9yIGkgaW4gcmFuZ2UobGVmdCwgcmlnaHQpOgogICAgICAgIGlmIGFbaV0gPT0gcmlnaHRfbToKICAgICAgICAgICAgcmlnaHRfY291bnQgKz0gMQogICAgaWYgcmlnaHRfY291bnQgPiAocmlnaHQtb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