{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE BangPatterns #-}

import Control.Monad
import Control.Monad.ST
import Control.Applicative
import Control.Monad.Primitive
import Data.List
import Data.Maybe
import Data.Bits
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.IntMap as IM

import Data.Time


readIntBS = fst . fromJust . BS.readInt

main :: IO ()
main = do
  n <- readLn :: IO Int
  as <- map readIntBS . BS.words <$> BS.getLine :: IO [Int]
  fen <- VUM.replicate (2*n+2) 0 :: IO (VUM.IOVector Int)

  let
    xs = VU.fromList $ sort as
    m = n*(n+1)`div`2
    solve l r
      | l == r = return l
      | l+1 == r = aux (xs VU.! r) >>= \a -> return $ if a then r else l
      | otherwise = do
          a <- aux $ (xs VU.! ((l+r)`div`2))
          if a then
            solve ((l+r)`div`2) r
            else
            solve l ((l+r)`div`2)
        where
          aux x = do

            VUM.set fen 0
            y <- sum <$>
              (forM (map (+(n+1)) . scanl (+) 0 $ map (\a -> if a >= x then 1 else -1) as) $
               \a -> sumFen a >>= \q -> addFen a >> return q)
            return $ y >= m`div`2
            

    size = 2*n+2

    {-# INLINE addFen #-}
    addFen :: Int -> IO ()
    addFen j = do
      when (j <= size) $ do
        VUM.unsafeWrite fen j =<< (+1) <$> VUM.unsafeRead fen j
        addFen (j + (j .&. (-j)))

    {-# INLINE sumFen #-}
    sumFen :: Int -> IO Int
    sumFen j
      | j <= 0 = return 0
      | otherwise = (+) <$> VUM.unsafeRead fen j <*> sumFen (j - (j .&. (-j)))

  --x <- getCurrentTime
  print =<< (xs VU.!) <$> solve 0 (n-1)
  --y <- getCurrentTime
  --print $ diffUTCTime y x
