# Uses python3  def get_majority_element(a, left, right):     if left == right:         return a[right]     if left + 1 == right:         if a[left] == a[right]:             return a[left]         else:             return -1     mid = (left + right) // 2     l_elem = get_majority_element(a, left, mid)     r_elem = get_majority_element(a, mid + 1, right)     #if r_elem != -1: print('right_elem_count = ' + str(a[left:right+1].count(r_elem)) + ' right = ' + str(right) + ' left = ' + str(left) + ' ' + str(a[left:right+1]))     #if l_elem != -1: print('left elem count  = ' + str(a[left:right+1].count(l_elem)) + ' right = ' + str(right) + ' left = ' + str(left) + ' ' + str(a[left:right+1]))          if (l_elem != -1) and (a[left:right+1].count(l_elem) > (right+1-left)//2):         return l_elem     if (r_elem != -1) and (a[left:right+1].count(r_elem) > (right+1-left)//2):         return r_elem      return -1  def get_majority_element2(a):     t = len(a)/2     counts = dict()     for e in a:         counts[e] = counts.get(e, 0) + 1     for value in counts.values():         if value > t:             return 1     return 0  ''' n = int(input()) a = list(map(int, input().split())) print(get_majority_element2(a)) '''  #n, *a = list(map(int, input().split())) n = int(input()) a = list(map(int, input().split())) if get_majority_element(a, 0 ,n-1) != -1:     print(1) else:     print(0) 