Codeforces Round 396 (Div. 2)
B
Mahmoud and a Triangle
Codeforces
1000
原题
← AC →
翻译中…

Mahmoud has $*n*$ line segments, the $*i*$-th of them has length $*a*_{*i*}$. Ehab challenged him to use exactly $3$ line segments to form a non-degenerate triangle. Mahmoud doesn't accept challenges unless he is sure he can win, so he asked you to tell him if he should accept the challenge. Given the lengths of the line segments, check if he can choose exactly $3$ of them to form a non-degenerate triangle.

翻译中…

Mahmoud should use exactly $3$ line segments, he can't concatenate two line segments or change any length. A non-degenerate triangle is a triangle with positive area.

翻译中…

Input

翻译中…

The first line contains single integer $*n*$ ($3 ≤ *n* ≤ 10^{5}$) — the number of line segments Mahmoud has.

翻译中…

The second line contains $*n*$ integers $*a*_{1}, *a*_{2}, ..., *a*_{*n*}$ ($1 ≤ *a*_{*i*} ≤ 10^{9}$) — the lengths of line segments Mahmoud has.

翻译中…

Output

翻译中…

In the only line print "YES" if he can choose exactly three line segments and form a non-degenerate triangle with them, and "NO" otherwise.

翻译中…

Note

翻译中…

For the first example, he can use line segments with lengths $2$, $4$ and $5$ to form a non-degenerate triangle.

翻译中…

样例

Input #1
5
1 5 3 2 4
Output #1
YES
InputCopy OutputCopy
Input #2
3
4 1 2
Output #2
NO
InputCopy OutputCopy
题目信息
题号
766B
时间限制
2 s
内存限制
256 MB
标签
构造
计算几何
贪心
数学
数论
排序

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