{"raw_statement":[{"iden":"statement","content":"Dima the hamster enjoys nibbling different things: cages, sticks, bad problemsetters and even trees!\n\nRecently he found a binary search tree and instinctively nibbled all of its edges, hence messing up the vertices. Dima knows that if Andrew, who has been thoroughly assembling the tree for a long time, comes home and sees his creation demolished, he'll get extremely upset.\n\nTo not let that happen, Dima has to recover the binary search tree. Luckily, he noticed that any two vertices connected by a direct edge had their greatest common divisor value exceed $1$.\n\nHelp Dima construct such a **binary search tree** or determine that it's impossible. The definition and properties of a binary search tree can be found [here.](https://en.wikipedia.org/wiki/Binary_search_tree)"},{"iden":"input","content":"The first line contains the number of vertices $n$ ($2 \\le n \\le 700$).\n\nThe second line features $n$ distinct integers $a_i$ ($2 \\le a_i \\le 10^9$) — the values of vertices **in ascending order**."},{"iden":"output","content":"If it is possible to reassemble the binary search tree, such that the greatest common divisor of any two vertices connected by the edge is greater than $1$, print \"_Yes_\" (quotes for clarity).\n\nOtherwise, print \"_No_\" (quotes for clarity)."},{"iden":"examples","content":"Input\n\n6\n3 6 9 18 36 108\n\nOutput\n\nYes\n\nInput\n\n2\n7 17\n\nOutput\n\nNo\n\nInput\n\n9\n4 8 10 12 15 18 33 44 81\n\nOutput\n\nYes"},{"iden":"note","content":"The picture below illustrates one of the possible trees for the first example.\n\n<center>![image](https://espresso.codeforces.com/0565eb6f41692a42daefd732c8539e0dfa52be65.png)</center>The picture below illustrates one of the possible trees for the third example.\n\n<center>![image](https://espresso.codeforces.com/179a7946d803f25aacfad4df0beda06a0413a3c0.png)</center>"}],"translated_statement":"[{\"iden\":\"statement\",\"content\":\"Dima the hamster enjoys nibbling different things: cages, sticks, bad problemsetters and even trees!\\n\\nRecently he found a binary search tree and instinctively nibbled all of its edges, hence messing up the vertices. Dima knows that if Andrew, who has been thoroughly assembling the tree for a long time, comes home and sees his creation demolished, he'll get extremely upset. \\n\\nTo not let that happen, Dima has to recover the binary search tree. Luckily, he noticed that any two vertices connected by a direct edge had their greatest common divisor value exceed $1$.\\n\\nHelp Dima construct such a *binary search tree* or determine that it's impossible. The definition and properties of a binary search tree can be found here.\\n\\nThe first line contains the number of vertices $n$ ($2 lt.eq n lt.eq 700$).\\n\\nThe second line features $n$ distinct integers $a_i$ ($2 lt.eq a_i lt.eq 10^9$) — the values of vertices *in ascending order*.\\n\\nIf it is possible to reassemble the binary search tree, such that the greatest common divisor of any two vertices connected by the edge is greater than $1$, print \\\"_Yes_\\\" (quotes for clarity).\\n\\nOtherwise, print \\\"_No_\\\" (quotes for clarity).\\n\\nThe picture below illustrates one of the possible trees for the first example.\\n\\nThe picture below illustrates one of the possible trees for the third example.\\n\\n\"},{\"iden\":\"input\",\"content\":\"The first line contains the number of vertices $n$ ($2 lt.eq n lt.eq 700$).The second line features $n$ distinct integers $a_i$ ($2 lt.eq a_i lt.eq 10^9$) — the values of vertices *in ascending order*.\"},{\"iden\":\"output\",\"content\":\"If it is possible to reassemble the binary search tree, such that the greatest common divisor of any two vertices connected by the edge is greater than $1$, print \\\"_Yes_\\\" (quotes for clarity).Otherwise, print \\\"_No_\\\" (quotes for clarity).\"},{\"iden\":\"examples\",\"content\":\"Input63 6 9 18 36 108OutputYesInput27 17OutputNoInput94 8 10 12 15 18 33 44 81OutputYes\"},{\"iden\":\"note\",\"content\":\"The picture below illustrates one of the possible trees for the first example.  The picture below illustrates one of the possible trees for the third example.  \"}]}","sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ n \\in \\mathbb{Z} $ with $ 2 \\leq n \\leq 700 $.  \nLet $ A = (a_1, a_2, \\dots, a_n) $ be a strictly increasing sequence of distinct integers with $ 2 \\leq a_i \\leq 10^9 $ for all $ i \\in \\{1, \\dots, n\\} $.\n\nA *binary search tree (BST)* on $ A $ is a rooted binary tree with vertex set $ \\{a_1, \\dots, a_n\\} $ such that for every vertex $ a_i $, all values in its left subtree are less than $ a_i $, and all values in its right subtree are greater than $ a_i $. Equivalently, the inorder traversal of the tree is $ A $.\n\nLet $ G = (V, E) $ be the undirected graph induced by the tree structure, where $ V = \\{a_1, \\dots, a_n\\} $ and $ E $ consists of parent-child edges.\n\n**Constraints**  \nFor every edge $ \\{u, v\\} \\in E $, it must hold that $ \\gcd(u, v) > 1 $.\n\n**Objective**  \nDetermine whether there exists a BST structure on $ A $ such that the above gcd condition is satisfied for all edges in the tree.  \nOutput \"Yes\" if such a tree exists; otherwise, output \"No\".","simple_statement":null,"has_page_source":false}