f str s m | null s = null m | null m = f str ts [x] | [x, y] == str = f str ts tm | otherwise = f str ts (x : m) where (x : ts) = s (y : tm) = m main :: IO () main = do n <- read <$> getLine :: IO Int s <- getLine let x = length $ filter (=='(') s y = length $ filter (==')') s bl1 = f "()" s [] bl2 = f ")(" s [] bl = bl1 || bl2 putStrLn $ if bl then "Yes" else "No"