Zaikia has $N$ sticks of distinct positive lengths $A_1,A_2,\dots,A_N$. For no good reason at all, he wants to know if there is a triplet of sticks which when connected end-to-end will form a non-trivial triangle. Here non-trivial refers to a triangle with positive area.
Help Zaikia know if such a triplet exists or not. If such a triplet exists, help him find the lexicographically largest applicable triplet.Input
- The first line contains an integer $N$.
- The second line contains $N$ space-seperated integers $A_1,A_2,\dots,A_N$. Output
- In the first line print YES if a triplet exists or NO if it doesn't.
- If such a triplet exists, then in the second line print the lexicographically largest applicable triplet.Constraints
- $3 \leq N \leq {2}\times{10}^{5}$
- $1 \leq A_i \leq {10}^{9}$ for each valid $i$Sample Input 1
5
4 2 10 3 5
Sample Output 1
YES
5 4 3
Explanation 1
There are three unordered triplets of sticks which can be used to create a triangle:
- $4,2,3$
- $4,2,5$
- $4,3,5$
Arranging them in lexicographically largest fashion
- $4,3,2$
- $5,4,2$
- $5,4,3$
Here $5,4,3$ is the lexicographically largest so it is the triplet which dristiron wantsSample Input 2
5
1 2 4 8 16
Sample Output 2
NO
Explanation 2
There are no triplets of sticks here that can be used to create a triangle.

Source: codechef | Difficulty: UNKNOWN_DIFFICULTY


Solutions:
n = int(input())
l = list(map(int, input().split()))
l1 = []
if n < 3:
	print('NO')
else:
	l.sort()
	for i in range(n - 2):
		if l[i] + l[i + 1] > l[i + 2]:
			l1.append([l[i + 2], l[i + 1], l[i]])
if len(l1) != 0:
	print('YES')
	print(*max(l1))
else:
	print('NO')


n = int(input())
arr = [int(i) for i in input().split()]
arr.sort()
new = []
check = 0
for i in range(2, n):
	if arr[i - 2] + arr[i - 1] > arr[i]:
		new.append((arr[i - 2], arr[i - 1], arr[i]))
if len(new) == 0:
	print('NO')
else:
	print('YES')
	ans = max(new)
	print(' '.join([str(i) for i in reversed(ans)]))


def checkValidity(a, b, c):
	if a + b <= c or a + c <= b or b + c <= a:
		return False
	else:
		return True
n = int(input())
li = list(map(int, input().split()))
li.sort(reverse=True)
y = len(li)
f = 0
for i in range(y - 2):
	for j in range(i + 1, y - 1):
		a = li[i]
		b = li[j]
		c = li[j + 1]
		if checkValidity(a, b, c):
			x = str(a) + ' ' + str(b) + ' ' + str(c)
			print('YES')
			print(x)
			f = 1
			break
	if f == 1:
		break
if f == 0:
	print('NO')


n = int(input())
nums = list(map(int, input().strip().split(' ')))
if n < 3:
	print('NO')
else:
	nums.sort(reverse=True)
	l = nums[0]
	m = nums[1]
	s = nums[2]
	trig = 1
	for i in range(0, n - 2):
		s = nums[i + 2]
		if l < m + s:
			trig = 0
			print('YES')
			print(l, m, s)
			break
		l = m
		m = s
	if trig:
		print('NO')


def isPossibleTriangle(arr, N, tri, alltri):
	arr.sort(reverse=True)
	flag = 0
	for i in range(N - 2):
		if arr[i] + arr[i + 1] > arr[i + 2] and arr[i] + arr[i + 2] > arr[i + 1] and (arr[i + 1] + arr[i + 2] > arr[i]):
			flag = 1
			tri.append(arr[i])
			tri.append(arr[i + 1])
			tri.append(arr[i + 2])
			alltri.append(tri)
			break
	if flag == 0:
		return 'NO'
	else:
		return 'YES'
N = int(input())
arr = list(map(int, input().split()))
tri = []
alltri = []
if isPossibleTriangle(arr, N, tri, alltri) == 'YES':
	alltri.sort()
	print('YES')
	print(*alltri[0])
else:
	print('NO')


def sticks(nums):
	ans = []
	it = 0
	while it < len(nums) - 2:
		if nums[it] + nums[it + 1] > nums[it + 2]:
			ans = []
			for p in range(2, -1, -1):
				ans.append(nums[it + p])
		it += 1
	if not nums:
		return False
	return ans
num = int(input())
nums = list(map(int, input().split()))
temp = sticks(sorted(nums))
if temp:
	print('YES')
	print(' '.join(list(map(str, temp))))
else:
	print('NO')


import sys
input = sys.stdin.readline
(inp, ip) = (lambda : int(input()), lambda : [int(w) for w in input().split()])
n = inp()
x = ip()
x.sort(reverse=True)
flag = 1
for i in range(n - 2):
	if x[i] < x[i + 1] + x[i + 2]:
		flag = 0
		print('YES')
		print(x[i], x[i + 1], x[i + 2])
		break
if flag:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
a.sort()
i = n - 3
ans = []
tmp = 0
while i >= 0:
	if a[i] + a[i + 1] > a[i + 2]:
		print('YES')
		print(a[i + 2], a[i + 1], a[i])
		tmp = 1
		break
	i -= 1
if tmp == 0:
	print('NO')


try:
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	ans = []
	for i in range(n - 2):
		a = []
		if l[i] + l[i + 1] > l[i + 2]:
			a.append(l[i])
			a.append(l[i + 1])
			a.append(l[i + 2])
			ans.append(a)
	if len(ans) != 0:
		s = []
		for j in ans:
			s.append(sum(j))
		m = s.index(max(s))
		print('YES')
		for i in reversed(ans[m]):
			print(i, end=' ')
	else:
		print('NO')
except:
	pass


def tri(arr, n):
	li1 = []
	arr = sorted(arr)
	z = 0
	for i in range(n - 2):
		li = []
		if arr[i] + arr[i + 1] > arr[i + 2]:
			li.append(arr[i])
			li.append(arr[i + 1])
			li.append(arr[i + 2])
			z = 1
		else:
			pass
		li1.append(li)
	if z == 0:
		print('NO')
	else:
		print('YES')
		m = sorted(max(li1), reverse=True)
		print(*m, sep=' ')
n = int(input())
a = [int(x) for x in input().split()]
tri(a, n)


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


n = int(input())
a = list(map(int, input().split()))
a.sort()
a = a[::-1]
s = set()
signal = False
for x in range(n):
	if not signal:
		for y in range(x + 1, n):
			if not signal:
				for z in range(y + 1, n):
					if a[x] + a[y] > a[z] and a[x] + a[z] > a[y] and (a[y] + a[z] > a[x]):
						l = [a[x], a[y], a[z]]
						signal = True
						break
if signal:
	print('YES')
	print(l[0], l[1], l[2])
else:
	print('NO')


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


N = int(input())
A = list(map(int, input().split()))
A.sort()
min = 0
for i in range(1, N - 2):
	if A[i + 2] < A[i] + A[i + 1]:
		min = i
if min == 0:
	if A[2] < A[0] + A[1]:
		value = 'YES'
	else:
		value = 'NO'
else:
	value = 'YES'
if value == 'YES':
	print(value)
	print(str(A[min + 2]) + ' ' + str(A[min + 1]) + ' ' + str(A[min]))
else:
	print(value)


import sys
tokenizedInput = sys.stdin.read().split()

def triplets(n, arr):
	array = sorted(arr, reverse=False)
	temp = []
	result = []
	i = 0
	for i in range(len(array)):
		if i < len(array) - 2:
			if array[i] + array[i + 1] > array[i + 2]:
				temp.append(array[i])
				temp.append(array[i + 1])
				temp.append(array[i + 2])
				i = 3
				temp = sorted(temp, reverse=False)
				for (i, num) in enumerate(temp):
					if temp[0] + temp[1] > temp[2]:
						result.append(sorted(temp, reverse=True))
				temp = []
			else:
				i += 1
	max = 0
	i = 0
	if result:
		for (count, eacharr) in enumerate(result):
			if eacharr[0] > max:
				max = eacharr[0]
				i = count
		listToStr = ' '.join([str(elem) for elem in result[i]])
		print('YES')
		print(listToStr)
	else:
		print('NO')

def main():
	lst = []
	n = list(map(int, tokenizedInput[:1]))
	lst = list(map(int, tokenizedInput[1:]))
	return triplets(n, lst)

def __starting_point():
	main()
__starting_point()


from sys import stdin, stdout
for _ in range(1):
	n = int(stdin.readline())
	a = sorted(map(int, stdin.readline().split()), reverse=True)
	ans = []
	for (x, y, z) in zip(a, a[1:], a[2:]):
		if x + y > z and x + z > y and (y + z > x):
			ans = [x, y, z]
			break
	if not ans:
		print('NO')
	else:
		print('YES')
		print(*ans)


n = int(input())
x = []
ans = 'NO'
arr = list(map(int, input().split()))
arr.sort()
for i in range(n - 2):
	if arr[i] + arr[i + 1] > arr[i + 2]:
		ans = 'YES'
		x.append(i)
print(ans)
if ans == 'YES':
	print(arr[max(x) + 2], arr[max(x) + 1], arr[max(x)])


try:
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	x = [-1, -1, -1]
	for i in range(n - 2):
		s = (a[i] + a[i + 1] + a[i + 2]) / 2
		if s > a[i + 2]:
			x[0] = a[i]
			x[1] = a[i + 1]
			x[2] = a[i + 2]
	if x[0] == x[1] == x[2] == -1:
		print('NO')
	else:
		x.sort()
		print('YES')
		print(x[2], x[1], x[0])
except EOFError:
	pass