{-# OPTIONS_GHC -O2 #-}

import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as V
import qualified Data.IntSet as S

msort xs
  | n==1 = xs
  | True = msort' 0 (msort us) (msort vs)
  where
    n = length xs
    (us,vs) = splitAt (n`div`2) xs

msort' c [] []          = []
msort' c ((x,xc):xs) [] = (x,xc+c) : msort' c xs []
msort' c [] (y:ys)      = y        : msort' (c+1) [] ys
msort' c xa@((x,xc):xs) ya@((y,yc):ys)
  | x<=y = (x,xc+c) : (msort' c xs ya)
  | True= (y,yc)   : (msort' (c+1) xa ys)

si as x = sum.map snd.msort.zip ss $ repeat 0
  where
    bs = map (\a->if a>=x then 1 else (-1)) as
    ss = scanl1 (+) bs

bsearch f (a,b)
    | a+1 == b = a
    | f m  = bsearch f (m,b)
    | True = bsearch f (a,m)
    where m = (a + (b-a)`div`2)

ff av as tn x = iv >= (tn+1) `div` 2
  where
    iv = (-) tn $ si as $ av V.! x

main=do
  n<-readLn::IO Int
  as<-unfoldr (B.readInt.B.dropWhile(==' '))<$>B.getLine::IO[Int]
  av<-pure $ V.fromList $ S.toList $ S.fromList as
  print $ (V.!) av $ bsearch (ff av as $ (n*(n-1))`div`2) (-1,V.length av)