
import Control.Monad

factorT = 1000

solve :: Int -> Int -> [Int] -> Int
solve t a hs = minByIdx (map d hs) where
    minByIdx = iter 1 0 (10000000*factorT)
    iter _ mi _ [] = mi
    iter i mi mx (x:xs)
        | mx > x    = iter (i+1) i  x  xs
        | otherwise = iter (i+1) mi mx xs   
    d h = abs (factorT*a - averageT t h) 
averageT t h = t*factorT - h*6 

readLine:: IO [Int]
readLine = fmap (map read . words) getLine

readLines :: Int -> IO [[Int]]
readLines = flip replicateM readLine
    
main :: IO() 
main = do
    [n]    <- readLine
    [t, a] <- readLine
    [l] <- readLines 1
    let ans = solve t a l
    print ans
