Anatoly Shalyto
시간 제한2초메모리 제한512 MB
정렬된 중복집합이 주어질 때, 모든 비어 있지 않은 부분 중복집합 중 중앙값과 최빈값 차이의 최댓값을 구한다.
문제
Median of a multiset of integers is the smallest integer such that at least half of the elements of the set are less than or equal to .
Mode of a multiset of integers is the value that occurs the most times in the multiset. If there are multiple such values the mode is the smallest.
Imbalance of a multiset is the absolute difference between the median and the mode.
A multiset is a subset of a multiset if for every value the number of its occurrences in isn't less than the number of its occurrences in .
You are given a multiset of integers. Consider its non-empty subset with the largest imbalance. Print that imbalance.
입력
The first line contains a single integer (), size of the multiset.
The second line contains integers (, elements of the multiset.
출력
Print a single integer --- the largest imbalance of some subset of the given multiset.