MemSQL Start[c]UP 2.0 - Round 1
F
Permutation
Codeforces
2700
原题
← E→
翻译中…

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 image (note, that it is usual division, not integer one) is between $*a*$ and $*b*$ in this permutation.

翻译中…

Input

翻译中…

First line consists of a single integer $*n*$ ($1 ≤ *n* ≤ 300000$) — the size of permutation.

翻译中…

Second line contains $*n*$ integers — the permutation itself.

翻译中…

Output

翻译中…

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

翻译中…

Note

翻译中…

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

翻译中…

样例

Input #1
4
1 3 4 2
Output #1
NO
InputCopy OutputCopy
Input #2
5
1 5 2 4 3
Output #2
YES
InputCopy OutputCopy
题目信息
题号
452F
时间限制
1 s
内存限制
256 MB
标签
数据结构
分治
哈希

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。