{"raw_statement":[{"iden":"statement","content":"A k-cyclic shift of an integer x is a function that removes the last k digits of x and inserts them in its beginning. For example, the k-cyclic shifts of 123 are 312 for k = 1 and 231 for k = 2.\n\nTeo, a kid from Canada, learned from his Canadian friends this definition of ugly numbers: a number is ugly if, and only if every one of its k-cyclic shifts returns a number greater than or equal to it.\n\nGiven an n-digit decimal number x, can you answer if it is ugly or not?\n\nThe first line of the input contains a single integer n (1 ≤ n ≤ 5 × 105), indicating the number of digits of the number.\n\nThe next line contains an n-digit decimal number, indicating the value of x.\n\nOutput \"Yes\" if x is an ugly number and \"No\" otherwise.\n\n"},{"iden":"input","content":"The first line of the input contains a single integer n (1 ≤ n ≤ 5 × 105), indicating the number of digits of the number.The next line contains an n-digit decimal number, indicating the value of x."},{"iden":"output","content":"Output \"Yes\" if x is an ugly number and \"No\" otherwise."},{"iden":"examples","content":"Input3123OutputYesInput42214OutputNo"}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ N \\in \\mathbb{Z}^+ $ be the number of verses.  \nLet $ L = (\\ell_1, \\ell_2, \\dots, \\ell_N) $ be a sequence of positive integers representing verse sizes.  \n\nFor $ K \\in \\mathbb{Z} $, $ K > 1 $, define the remainder distribution:  \n$ r_K(i) = \\left| \\left\\{ j \\in \\{1, \\dots, N\\} \\mid \\ell_j \\equiv i \\pmod{K} \\right\\} \\right| $ for $ i = 0, 1, \\dots, K-1 $.  \n\nThe poem is $ K $-elegant if:  \n1. $ K > 1 $,  \n2. $ K \\mid N $,  \n3. $ r_K(i) = \\frac{N}{K} $ for all $ i \\in \\{0, 1, \\dots, K-1\\} $.  \n\n**Objective**  \nFind the smallest integer $ K > 1 $ such that the poem is $ K $-elegant. If no such $ K $ exists, output $-1$.","simple_statement":"Find the smallest K > 1 such that in a poem of N verses, the verse lengths mod K produce exactly N/K verses for each remainder 0, 1, ..., K-1. If no such K exists, print -1.","has_page_source":false}