import Data.List

cmp [] [] = True
cmp (a:as) (b:bs) = if a /= b then False else cmp as bs

ans :: Int -> [Int] -> Int -> [Int]
ans n c k =
  if n == k
  then [n]
  else
    let a = sort $ take k c
        b = sort $ drop (n-k) c
        x = ans n c (k+1)
    in
      if cmp a b
      then k:x
      else x

main = do
  n <- getLine
  c <- getLine
  let n' = read n :: Int
      c' = map read $ words c :: [Int]
      o  = ans n' c' 1
  putStrLn $ unwords $ map show o

