Permutation

题意翻译

## 题目描述 给你一个1到n的排列,你需要判断该排列内部是否存在一个3个元素的子序列(可以不连续),使得这个子序列是等差序列。 ## 输入输出格式 ### 输入格式: 第一行一个整数$n(n\leq 3\times10^5)$,表示给出的序列的长度。 第二行有$n$个整数,表示这个排列。 ### 输出格式: 如果存在,输出`YES`,反之输出`NO`。答案的大小写无所谓。

题目描述

You are given a permutation of numbers from $ 1 $ to $ n $ . Determine whether there's a pair of integers $ a,b $ $ (1<=a,b<=n; a≠b) $ such that the element ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF452F/79a61ff17360227fbc1ddd07b61b3ec2cf482ac4.png) (note, that it is usual division, not integer one) is between $ a $ and $ b $ in this permutation.

输入输出格式

输入格式


First line consists of a single integer $ n $ ( $ 1<=n<=300000 $ ) — the size of permutation. Second line contains $ n $ integers — the permutation itself.

输出格式


Print "YES", if such a pair exists, "NO" otherwise (in both cases without quotes, the answer is case insensitive).

输入输出样例

输入样例 #1

4
1 3 4 2

输出样例 #1

NO

输入样例 #2

5
1 5 2 4 3

输出样例 #2

YES

说明

In the second example $ 2 $ is between $ 1 $ and $ 3 $ . Additionally $ 4 $ is between $ 3 $ and $ 5 $ .