import qualified Data.ByteString.Char8 as C
import Data.List

main = C.interact $ C.pack . show . sol . get

get = map (unfoldr (C.readInt . C.dropWhile (<'0'))) . C.lines

sol ([n]:is) = (+1) $ (-) <$> (f . sort . map last) <*> (f . sort . map head) $ is
  where
  f | odd n     = (!!h)
    | otherwise = (+) <$> (!!h) <*> (!!(h-1))
  h = n `div` 2