main = do
    _ <- getLine
    a <- getLine
    _ <- getLine
    m <- getLine
    let a' = sort $ map read $ words a :: [Int]
        m' = map read $ words m :: [Int]
        o  = map (\ m -> ans m a') m'
--    print o
    mapM_ putStrLn o
main = do
    _ <- getLine
    a <- getLine
    _ <- getLine
    m <- getLine
    let a' = sort $ map read $ words a :: [Int]
        m' = map read $ words m :: [Int]
        o  = map (\ m -> ans m a') m'
--    print o
    mapM_ putStrLn o
main = do
    _ <- getLine
    a <- getLine
    _ <- getLine
    m <- getLine
    let a' = sort $ map read $ words a :: [Int]
        m' = map read $ words m :: [Int]
        o  = map (\ m -> ans m a') m'
--    print o
    mapM_ putStrLn o