{"raw_statement":[{"iden":"statement","content":"Vlad likes to eat in cafes very much. During his life, he has visited cafes _n_ times. Unfortunately, Vlad started to feel that his last visits are not any different from each other. To fix that Vlad had a small research.\n\nFirst of all, Vlad assigned individual indices to all cafes. Then, he wrote down indices of cafes he visited in a row, in order of visiting them. Now, Vlad wants to find such a cafe that his last visit to that cafe was before his last visits to every other cafe. In other words, he wants to find such a cafe that he hasn't been there for as long as possible. Help Vlad to find that cafe."},{"iden":"input","content":"In first line there is one integer _n_ (1 ≤ _n_ ≤ 2·105) — number of cafes indices written by Vlad.\n\nIn second line, _n_ numbers _a_1, _a_2, ..., _a__n_ (0 ≤ _a__i_ ≤ 2·105) are written — indices of cafes in order of being visited by Vlad. Vlad could visit some cafes more than once. Note that in numeration, some indices could be omitted."},{"iden":"output","content":"Print one integer — index of the cafe that Vlad hasn't visited for as long as possible."},{"iden":"examples","content":"Input\n\n5\n1 3 2 1 2\n\nOutput\n\n3\n\nInput\n\n6\n2 1 2 2 4 1\n\nOutput\n\n2"},{"iden":"note","content":"In first test, there are three cafes, and the last visits to cafes with indices 1 and 2 were after the last visit to cafe with index 3; so this cafe is the answer.\n\nIn second test case, there are also three cafes, but with indices 1, 2 and 4. Cafes with indices 1 and 4 were visited after the last visit of cafe with index 2, so the answer is 2. Note that Vlad could omit some numbers while numerating the cafes."}],"translated_statement":[{"iden":"statement","content":"Vlad 非常喜欢去咖啡馆吃饭。在他的一生中，他一共访问了 #cf_span[n] 次咖啡馆。不幸的是，Vlad 开始觉得最近的几次访问彼此之间没有任何区别。为了解决这个问题，Vlad 做了一项小研究。\n\n首先，Vlad 给所有咖啡馆分配了独立的编号。然后，他按访问顺序记录了他访问过的咖啡馆编号。现在，Vlad 希望找到这样一个咖啡馆：他最后一次访问该咖啡馆的时间，早于他最后一次访问其他所有咖啡馆的时间。换句话说，他想找到一个他最久没有去过的咖啡馆。请帮助 Vlad 找到这个咖啡馆。\n\n第一行包含一个整数 #cf_span[n] (#cf_span[1 ≤ n ≤ 2·105]) —— Vlad 记录的咖啡馆编号数量。\n\n第二行包含 #cf_span[n] 个数字 #cf_span[a1, a2, ..., an] (#cf_span[0 ≤ ai ≤ 2·105]) —— Vlad 访问咖啡馆的顺序编号。Vlad 可能多次访问同一个咖啡馆。注意，在编号过程中，某些编号可能被跳过。\n\n请输出一个整数 —— Vlad 最久没有去过的咖啡馆的编号。\n\n在第一个测试中，共有三个咖啡馆，编号为 #cf_span[1] 和 #cf_span[2] 的咖啡馆的最后一次访问都发生在编号为 #cf_span[3] 的咖啡馆之后；因此，编号为 #cf_span[3] 的咖啡馆是答案。\n\n在第二个测试用例中，同样有三个咖啡馆，但编号为 #cf_span[1]、#cf_span[2] 和 #cf_span[4]。编号为 #cf_span[1] 和 #cf_span[4] 的咖啡馆的最后一次访问都发生在编号为 #cf_span[2] 的咖啡馆之后，因此答案是 #cf_span[2]。请注意，Vlad 在编号咖啡馆时可能会跳过某些数字。"},{"iden":"input","content":"第一行包含一个整数 #cf_span[n] (#cf_span[1 ≤ n ≤ 2·105]) —— Vlad 记录的咖啡馆编号数量。第二行包含 #cf_span[n] 个数字 #cf_span[a1, a2, ..., an] (#cf_span[0 ≤ ai ≤ 2·105]) —— Vlad 访问咖啡馆的顺序编号。Vlad 可能多次访问同一个咖啡馆。注意，在编号过程中，某些编号可能被跳过。"},{"iden":"output","content":"请输出一个整数 —— Vlad 最久没有去过的咖啡馆的编号。"},{"iden":"examples","content":"输入\n5\n1 3 2 1 2\n输出\n3\n\n输入\n6\n2 1 2 2 4 1\n输出\n2"},{"iden":"note","content":"在第一个测试中，共有三个咖啡馆，编号为 #cf_span[1] 和 #cf_span[2] 的咖啡馆的最后一次访问都发生在编号为 #cf_span[3] 的咖啡馆之后；因此，编号为 #cf_span[3] 的咖啡馆是答案。在第二个测试用例中，同样有三个咖啡馆，但编号为 #cf_span[1]、#cf_span[2] 和 #cf_span[4]。编号为 #cf_span[1] 和 #cf_span[4] 的咖啡馆的最后一次访问都发生在编号为 #cf_span[2] 的咖啡馆之后，因此答案是 #cf_span[2]。请注意，Vlad 在编号咖啡馆时可能会跳过某些数字。"}],"sample_group":[],"show_order":[],"formal_statement":"Let $ n \\in \\mathbb{N} $, $ n \\geq 1 $, and let $ a = (a_1, a_2, \\dots, a_n) $ be a sequence of integers such that $ 0 \\leq a_i \\leq 2 \\cdot 10^5 $ for all $ i \\in \\{1, 2, \\dots, n\\} $.\n\nFor each distinct cafe index $ c \\in \\{a_1, a_2, \\dots, a_n\\} $, define $ \\ell(c) $ as the **last position** in the sequence where $ c $ appears, i.e.,\n$$\n\\ell(c) = \\max \\{ i \\in \\{1, 2, \\dots, n\\} \\mid a_i = c \\}.\n$$\n\nLet $ C = \\{ a_1, a_2, \\dots, a_n \\} $ be the set of distinct cafe indices appearing in the sequence.\n\nWe seek the cafe index $ c^* \\in C $ such that:\n$$\n\\ell(c^*) = \\min_{c \\in C} \\ell(c).\n$$\n\nIf multiple such $ c $ exist, output any one (the problem implies uniqueness in context, but formally, we take the minimum index among those achieving the minimum last occurrence).\n\n**Output:** $ c^* $, the cafe index with the earliest last occurrence.","simple_statement":null,"has_page_source":false}