import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    (d1 : d2 : _) <- drop (n `div` 2 - 1) . sort <$> getIntList
    print $ if d1 == d2 then 0 else d2 - d1 + 1