-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Char (isSpace)
import Control.Monad
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS
import Debug.Trace

loopL :: U.Vector Int -> Int -> Int -> Int -> Int
loopL vec x l h
  | l+1 == h = h
  | otherwise = let m = (l + h) `quot` 2
                in case compare x (vec U.! m) of
                     GT -> loopL vec x m h
                     EQ -> loopL vec x l m
                     LT -> error "invalid"

loopH :: U.Vector Int -> Int -> Int -> Int -> Int
loopH vec x l h | l+1 == h = h
                | otherwise = let m = (l + h) `quot` 2
                              in case compare x (vec U.! m) of
                                   LT -> loopH vec x l m
                                   EQ -> loopH vec x m h
                                   GT -> error "invalid"

check :: Int -> U.Vector Int -> Bool
check 1 !vec = True
check !n !vec | U.last v1 < U.head v2 = check n2 v2
              | otherwise = check n2 v2 && U.and (U.zipWith (<) v1 v2)
  where (v1, v2) = U.splitAt n2 vec
        n2 = n `quot` 2

main = do
  n <- readLn :: IO Int -- 1 <= n <= 18
  xs <- mergeSort . U.unfoldrN (2^n) (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  if check (2^n) xs
    then putStrLn "Yes"
    else putStrLn "No"

mergeSortBy :: (U.Unbox a) => (a -> a -> Ordering) -> U.Vector a -> U.Vector a
mergeSortBy !cmp !vec = doSort vec
  where
    doSort vec | U.length vec <= 1 = vec
               | otherwise = let (xs, ys) = U.splitAt (U.length vec `quot` 2) vec
                             in merge (doSort xs) (doSort ys)
    merge xs ys = U.create $ do
      let !n = U.length xs
          !m = U.length ys
      result <- UM.new (n + m)
      let loop !i !j
            | i == n = U.copy (UM.drop (i + j) result) (U.drop j ys)
            | j == m = U.copy (UM.drop (i + j) result) (U.drop i xs)
            | otherwise = let !x = xs U.! i
                              !y = ys U.! j
                          in case cmp x y of
                               LT -> do UM.write result (i + j) x
                                        loop (i + 1) j
                               EQ -> do UM.write result (i + j) x
                                        UM.write result (i + j + 1) y
                                        loop (i + 1) (j + 1)
                               GT -> do UM.write result (i + j) y
                                        loop i (j + 1)
      loop 0 0
      return result

mergeSort :: (U.Unbox a, Ord a) => U.Vector a -> U.Vector a
mergeSort = mergeSortBy compare
