{"raw_statement":[{"iden":"statement","content":"Array of integers is _unimodal_, if:\n\n*   it is strictly increasing in the beginning;\n*   after that it is constant;\n*   after that it is strictly decreasing.\n\nThe first block (increasing) and the last block (decreasing) may be absent. It is allowed that both of this blocks are absent.\n\nFor example, the following three arrays are unimodal: \\[5, 7, 11, 11, 2, 1\\], \\[4, 4, 2\\], \\[7\\], but the following three are not unimodal: \\[5, 5, 6, 6, 1\\], \\[1, 2, 1, 2\\], \\[4, 5, 5, 6\\].\n\nWrite a program that checks if an array is unimodal."},{"iden":"input","content":"The first line contains integer _n_ (1 ≤ _n_ ≤ 100) — the number of elements in the array.\n\nThe second line contains _n_ integers _a_1, _a_2, ..., _a__n_ (1 ≤ _a__i_ ≤ 1 000) — the elements of the array."},{"iden":"output","content":"Print \"_YES_\" if the given array is unimodal. Otherwise, print \"_NO_\".\n\nYou can output each letter in any case (upper or lower)."},{"iden":"examples","content":"Input\n\n6\n1 5 5 5 4 2\n\nOutput\n\nYES\n\nInput\n\n5\n10 20 30 20 10\n\nOutput\n\nYES\n\nInput\n\n4\n1 2 1 2\n\nOutput\n\nNO\n\nInput\n\n7\n3 3 3 3 3 3 3\n\nOutput\n\nYES"},{"iden":"note","content":"In the first example the array is unimodal, because it is strictly increasing in the beginning (from position 1 to position 2, inclusively), that it is constant (from position 2 to position 4, inclusively) and then it is strictly decreasing (from position 4 to position 6, inclusively)."}],"translated_statement":[{"iden":"statement","content":"整数数组是_单峰的_，当且仅当：\n\n存在一个下标 $i$，使得序列从第一个元素到第 $i$ 个元素非严格递增，从第 $i$ 个元素到最后一个元素非严格递减。\n\n第一个块（递增）和最后一个块（递减）可以不存在。允许这两个块都不存在。\n\n例如，以下三个数组是单峰的：#cf_span[[5, 7, 11, 11, 2, 1]]，#cf_span[[4, 4, 2]]，#cf_span[[7]]；但以下三个不是单峰的：#cf_span[[5, 5, 6, 6, 1]]，#cf_span[[1, 2, 1, 2]]，#cf_span[[4, 5, 5, 6]]。\n\n编写一个程序，判断一个数组是否为单峰的。\n\n第一行包含整数 #cf_span[n]（#cf_span[1 ≤ n ≤ 100]）——数组中元素的个数。\n\n第二行包含 #cf_span[n] 个整数 #cf_span[a1, a2, ..., an]（#cf_span[1 ≤ ai ≤ 1 000]）——数组的元素。\n\n如果给定数组是单峰的，请输出 \"_YES_\"；否则输出 \"_NO_\"。\n\n你可以以任意大小写输出每个字母。\n\n在第一个示例中，数组是单峰的，因为从位置 #cf_span[1] 到位置 #cf_span[2]（包含）严格递增，从位置 #cf_span[2] 到位置 #cf_span[4]（包含）为常数，然后从位置 #cf_span[4] 到位置 #cf_span[6]（包含）严格递减。\n\n"},{"iden":"input","content":"第一行包含整数 #cf_span[n]（#cf_span[1 ≤ n ≤ 100]）——数组中元素的个数。第二行包含 #cf_span[n] 个整数 #cf_span[a1, a2, ..., an]（#cf_span[1 ≤ ai ≤ 1 000]）——数组的元素。"},{"iden":"output","content":"如果给定数组是单峰的，请输出 \"_YES_\"；否则输出 \"_NO_\"。你可以以任意大小写输出每个字母。"},{"iden":"examples","content":"输入61 5 5 5 4 2输出YES输入510 20 30 20 10输出YES输入41 2 1 2输出NO输入73 3 3 3 3 3 3输出YES"},{"iden":"note","content":"在第一个示例中，数组是单峰的，因为从位置 #cf_span[1] 到位置 #cf_span[2]（包含）严格递增，从位置 #cf_span[2] 到位置 #cf_span[4]（包含）为常数，然后从位置 #cf_span[4] 到位置 #cf_span[6]（包含）严格递减。"}],"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ n \\in \\mathbb{Z} $ be the length of the array.  \nLet $ A = (a_1, a_2, \\dots, a_n) $ be a sequence of integers.\n\n**Constraints**  \n1. $ 1 \\leq n \\leq 100 $  \n2. $ 1 \\leq a_i \\leq 1000 $ for all $ i \\in \\{1, \\dots, n\\} $\n\n**Objective**  \nDetermine whether $ A $ is *unimodal*, i.e., there exists an index $ p \\in \\{1, \\dots, n\\} $ such that:  \n- $ a_1 \\leq a_2 \\leq \\dots \\leq a_p $ (non-decreasing prefix),  \n- $ a_p \\geq a_{p+1} \\geq \\dots \\geq a_n $ (non-increasing suffix).  \n\nThe increasing and/or decreasing segments may be empty (i.e., $ p = 1 $ or $ p = n $ is allowed).  \n\nOutput \"YES\" if such $ p $ exists; otherwise, output \"NO\".","simple_statement":null,"has_page_source":false}