An Array and Medians of Subarrays
Let's call the median of an array of length the number that appears in position after sorting its elements in non-decreasing order. For example, the medians of the arrays , , and are , , and , respectively.
You are given an array of integers of even length .
Determine whether it is possible to split into several subarrays of odd length such that all the medians of these subarrays are pairwise equal.
Formally, you need to determine whether there exists a sequence of integers such that the following conditions are satisfied:
;
;
, where denotes the subarray consisting of elements , and denotes the median of the array .
Input
The first line contains a single even integer () — the length of the array.
The second line contains integers ( — the elements of the array.
It is guaranteed that is even.
Output
Output "Yes
" if it is possible to divide into several subarrays of odd length in such a way that all medians of these subarrays are pairwise equal, and "No
" otherwise.
Examples
Note
In the first example, the array can be divided into the arrays and with medians equal to .
In the second example, the array can be divided into the arrays and with medians equal to .
In the third example, the array cannot be divided into several arrays of odd length with the same median values.
Scoring
( points): ;
( points): for ;
( points): for ;
( points): for ; each value occurs in no more than times;
( points): ;
( points): ;
( points): no additional restrictions.