import Control.Monad
import qualified Data.ByteString.Char8 as C
import Data.List
import qualified Data.Set as S

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

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

sol :: [[Int]] -> Int
sol is = S.size . S.fromList . map g $ f js
  where
  mn = floor . (/2) . fromIntegral . g $ map head is
  mx = ceiling . (/2) . fromIntegral . g $ map last is
  js = map (enumFromTo <$> (max mn . head) <*> (min mx . last)) is

f = foldr ((<*>) . ((:) <$>)) [[]]

g xs 
  | odd n     = 2*ys!!h
  | otherwise = ys!!(h-1) + ys!!h
  where
  ys = sort xs
  n = length xs
  h = n `div` 2