{"raw_statement":[{"iden":"statement","content":"As you could know there are no male planes nor female planes. However, each plane on Earth likes some other plane. There are _n_ planes on Earth, numbered from 1 to _n_, and the plane with number _i_ likes the plane with number _f__i_, where 1 ≤ _f__i_ ≤ _n_ and _f__i_ ≠ _i_.\n\nWe call a love triangle a situation in which plane _A_ likes plane _B_, plane _B_ likes plane _C_ and plane _C_ likes plane _A_. Find out if there is any love triangle on Earth."},{"iden":"input","content":"The first line contains a single integer _n_ (2 ≤ _n_ ≤ 5000) — the number of planes.\n\nThe second line contains _n_ integers _f_1, _f_2, ..., _f__n_ (1 ≤ _f__i_ ≤ _n_, _f__i_ ≠ _i_), meaning that the _i_\\-th plane likes the _f__i_\\-th."},{"iden":"output","content":"Output «_YES_» if there is a love triangle consisting of planes on Earth. Otherwise, output «_NO_».\n\nYou can output any letter in lower case or in upper case."},{"iden":"examples","content":"Input\n\n5\n2 4 5 1 3\n\nOutput\n\nYES\n\nInput\n\n5\n5 5 5 5 1\n\nOutput\n\nNO"},{"iden":"note","content":"In first example plane 2 likes plane 4, plane 4 likes plane 1, plane 1 likes plane 2 and that is a love triangle.\n\nIn second example there are no love triangles."}],"translated_statement":[{"iden":"statement","content":"正如你所知，飞机没有性别之分。然而，地球上每架飞机都喜欢另一架飞机。地球上共有 #cf_span[n] 架飞机，编号从 #cf_span[1] 到 #cf_span[n]，编号为 #cf_span[i] 的飞机喜欢编号为 #cf_span[fi] 的飞机，其中 #cf_span[1 ≤ fi ≤ n] 且 #cf_span[fi ≠ i]。\n\n我们称一个“爱情三角形”为一种情况：飞机 #cf_span[A] 喜欢飞机 #cf_span[B]，飞机 #cf_span[B] 喜欢飞机 #cf_span[C]，飞机 #cf_span[C] 喜欢飞机 #cf_span[A]。请判断地球上是否存在这样的爱情三角形。\n\n第一行包含一个整数 #cf_span[n] (#cf_span[2 ≤ n ≤ 5000]) —— 飞机的数量。\n\n第二行包含 #cf_span[n] 个整数 #cf_span[f1, f2, ..., fn] (#cf_span[1 ≤ fi ≤ n], #cf_span[fi ≠ i])，表示第 #cf_span[i] 架飞机喜欢第 #cf_span[fi] 架飞机。\n\n如果存在由地球上的飞机组成的爱情三角形，请输出 «_YES_»；否则输出 «_NO_»。\n\n你可以使用任意大小写字母输出。\n\n在第一个例子中，飞机 #cf_span[2] 喜欢飞机 #cf_span[4]，飞机 #cf_span[4] 喜欢飞机 #cf_span[1]，飞机 #cf_span[1] 喜欢飞机 #cf_span[2]，构成一个爱情三角形。\n\n在第二个例子中，不存在爱情三角形。\n\n"},{"iden":"input","content":"第一行包含一个整数 #cf_span[n] (#cf_span[2 ≤ n ≤ 5000]) —— 飞机的数量。第二行包含 #cf_span[n] 个整数 #cf_span[f1, f2, ..., fn] (#cf_span[1 ≤ fi ≤ n], #cf_span[fi ≠ i])，表示第 #cf_span[i] 架飞机喜欢第 #cf_span[fi] 架飞机。"},{"iden":"output","content":"如果存在由地球上的飞机组成的爱情三角形，请输出 «_YES_»；否则输出 «_NO_»。你可以使用任意大小写字母输出。"},{"iden":"examples","content":"输入52 4 5 1 3输出YES输入55 5 5 5 1输出NO"},{"iden":"note","content":"在第一个例子中，飞机 #cf_span[2] 喜欢飞机 #cf_span[4]，飞机 #cf_span[4] 喜欢飞机 #cf_span[1]，飞机 #cf_span[1] 喜欢飞机 #cf_span[2]，构成一个爱情三角形。在第二个例子中，不存在爱情三角形。"}],"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ n \\in \\mathbb{Z} $ be the number of planes, with $ 2 \\leq n \\leq 5000 $.  \nLet $ f: \\{1, 2, \\dots, n\\} \\to \\{1, 2, \\dots, n\\} $ be a function such that $ f(i) \\neq i $ for all $ i $, representing the plane that plane $ i $ likes.\n\n**Constraints**  \nFor all $ i \\in \\{1, \\dots, n\\} $:  \n- $ 1 \\leq f(i) \\leq n $  \n- $ f(i) \\neq i $\n\n**Objective**  \nDetermine whether there exist distinct indices $ a, b, c \\in \\{1, \\dots, n\\} $ such that:  \n$$\nf(a) = b, \\quad f(b) = c, \\quad f(c) = a\n$$  \nIf such a triple exists, output \"YES\"; otherwise, output \"NO\".","simple_statement":null,"has_page_source":false}