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.


-----Examples-----
Input
5
1 5 3 2 4

Output
YES

Input
3
4 1 2

Output
NO



-----Note-----

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

Difficulty: interview

Starter code:

Solutions:
n = int(input())
a = list(map(int, input().split()))
a.sort()
ok = False
for i in range(n - 2):
	if a[i] + a[i + 1] > a[i + 2]:
		ok = True
print(("NO", "YES")[ok])

read = lambda: map(int, input().split())
n = int(input())
a = sorted(read())
for i in range(2, n):
    if a[i - 2] + a[i - 1] > a[i]:
        print('YES')
        break
else:
    print('NO')

n = int(input())
k = sorted(map(int, input().split()))
for i in range(n - 2):
    if (k[i] + k[i + 1] > k[i + 2]):
        print("YES")
        break
else:
    print("NO")

input()
a = list(map(int, input().split()))
a.sort()

for i in range(len(a) - 2):
	if a[i] + a[i+1] > a[i+2]:
		print('YES')
		return

print('NO')

n = int(input())
arr = list(map(int, input().split()))
arr.sort()
for i in range(n - 2):
    a, b, c = arr[i], arr[i + 1], arr[i + 2]
    if a + b > c:
        print('YES')
        return
print('NO')




n = int(input())
A = sorted([int(x) for x in input().split()])


found = False
for i in range(n - 2):
    if A[i] + A[i + 1] > A[i + 2]:
        found = True

if found:
    print("YES")
else:
    print("NO")


def inp():
    return map(int, input().split(' '))


def is_tr(a, b, c):
    if a < b + c:
        if b < a + c:
            if c < b + a:
                return True
    return False


n = int(input())
a = list(inp())
a.sort()

for i in range(n-2):
    if is_tr(a[i], a[i+1], a[i+2]):
        print('YES')
        return
print('NO')

n = int(input())
x = list(map(int, input().strip().split(' ')))

x.sort()
try:
    znak = True
    for i in range(len(x)):
        for j in range(i + 1, len(x) - 1):
            if x[i] + x[j] > x[j+1]:
                print('YES')
                znak = False
                1/0
    if znak:
        print('NO')
    
except:
    pass


n = int(input())
a = list(map(int, input().split()))
a.sort()
f = False
for i in range(n - 2):
    if a[i] + a[i + 1] > a[i + 2]:
        f = True
if f:
    print("YES")
else:
    print("NO")


#!/bin/python3
import sys
n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
for i in range(0,n-2):
    if a[i] + a[i + 1] > a[i+2]:
        print("YES")
        return
print("NO")


def __starting_point():
	n, = map(int, input().split())
	a = list(map(int, input().split()))
	res = False
	a.sort()
	for i in range(1, n-1):
		if a[i-1] + a[i] > a[i+1]:
			res = True
			break
	if res:
		print("YES")
	else:
		print("NO")
__starting_point()

import math, sys, itertools

def main():
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	for i in range(n-2):
		if a[i]+a[i+1]>a[i+2]:
			print('YES')
			return
	print('NO')
			
		
		
		 
			

def __starting_point():
	main()

__starting_point()

# Author: Maharshi Gor

def read(type=int):
    return type(input())

def read_arr(type=int):
    return [type(token) for token in input().split()]

n = read()
A =  read_arr()

A.sort()
found = False
for i in range(len(A)-2):
    if A[i] + A[i+1] > A[i+2]:
        found = True
        break
if found:
    print("YES")
else:
    print("NO")


def isPossible(a):
    n = len(a)
    for i in range(2,n):
        if a[i] < a[i-1] + a[i-2]:
            return True
    return False



def __starting_point():
    n = int(input().strip())
    a = list(map(int, input().strip().split()))
    a = sorted(a)

    if isPossible(a):
        print("YES")
    else:
        print("NO")


    


__starting_point()

n = int(input())
a = [int(el) for el in input().split()]

a.sort()
for i in range(n - 2):
	b, c, d = a[i], a[i+1], a[i+2]
	if b + c > d:
		print('YES')
		break
else:
	print('NO')


n = int(input())
a = [int(s) for s in input().split()]
a.sort()
flag = False
for i in range(len(a) - 2):
    if a[i] + a[i + 1] > a[i + 2]:
        flag = True
        break

if (flag):
    print('YES')
else:
    print('NO')


n = int(input())

d = [int(i) for i in input().split()]

d.sort()

for i in range(n - 2):
    a = d[i]
    b = d[i + 1]
    c = d[i + 2]
    if a + b > c and a + c > b and b + c > a:
        print("YES")
        break
else:
    print("NO")

#!/usr/bin/env python3
def ri():
    return list(map(int, input().split()))

n = int(input())

a = list(ri())

a.sort()

for i in range(len(a)-2):
    if a[i] + a[i+1] > a[i+2]:
        print("YES")
        return

print("NO")


n=int(input())
a=sorted(map(int,input().split(" ")))
f=False
for i in range(n-2):
    if a[i]+a[i+1]>a[i+2]:
        f=True
print("YES" if f else "NO")

n = int(input())
a = sorted(map(int,input().split(' ')))

ans = "NO"
for i in range(n-2):
    if a[i] + a[i+1] > a[i+2]:
        ans = "YES"
print(ans)


n=int(input())
ar=list(map(int,input().split()))
ar.sort()
fl=False
for i in range(1,n-1):
    if ar[n-i]<ar[n-i-1]+ar[n-i-2]:
        fl=True
        break
if fl:
    print("YES")
else:
    print("NO")


n=int(input())
arr = list(map(int, input().split()))
arr.sort()

i,j=0,1
ans = 'NO'
while(j<n-1):
    sm = arr[i]+arr[j]
    if(sm>arr[j+1]):
        ans = 'YES'
        break
    else:
        i+=1
        j+=1
print(ans)

n=int(input())
l=list(map(int,input().split()))
l=sorted(l)
c=0
for i in range(n-2) :
    if l[i]+l[i+1]>l[i+2] :
        c=1
        break
if c==1 :
    print('YES')
else :
    print('NO')


from collections import deque

def main():
    from sys import stdin
    lines = deque(line.strip() for line in stdin.readlines())
    # lines will now contain all of the input's lines in a list
    n = int(lines[0])
    nums = sorted(int(x) for x in lines[1].split())
    for i in range(2, n):
        if nums[i-2] + nums[i-1] > nums[i]:
            print("YES")
            return
    print("NO")

def __starting_point():
    main()

__starting_point()

import sys

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    n = int(input())
    A = [int(i) for i in input().split()]

    A.sort()

    for i in range(n - 2):
        if A[i] + A[i + 1] > A[i + 2]:
            print('YES')
            return
    else:
        print('NO')


def __starting_point():
    solve()
__starting_point()