def new(iota, k1):
z=len(iota)
if z==0:
return 0
elif z==1:
return 1
else:
c1=iota[1][0]-iota[0][0]
d1=iota[1][1]-iota[0][1]
e1=d1*iota[0][0]-c1*iota[0][1]
if 2*c1!=k1*d1:
return 0
else:
for j in range(2, z):
if c1*iota[j][1]+e1!=d1*iota[j][0]:
break
else:
return 1
return 0
n=int(input())
w=[int(k) for k in input().split()]
k1=w[1]-w[0]
b1=w[0]
iota=[]
for j in range(2, n):
if k1*j+b1!=w[j]:
iota.append((w[j], j))
check=new(iota, 2*k1)
k1=w[2]-w[0]
b1=2*w[0]
iota=[]
if 2*w[1]!=k1+b1:
iota.append((w[1], 1))
for j in range(3, n):
if k1*j+b1!=2*w[j]:
iota.append((w[j], j))
check=max(check, new(iota, k1))
k1=w[2]-w[1]
b1=w[1]-k1
iota=[]
if b1!=w[0]:
iota.append((w[0], 0))
for j in range(3, n):
if k1*j+b1!=w[j]:
iota.append((w[j], j))
check=max(check, new(iota, 2*k1))
if check:
print("YES")
else:
print("NO")
660A - Co-prime Array | 1692F - 3SUM |
1470A - Strange Birthday Party | 190D - Non-Secret Cypher |
1721B - Deadly Laser | 1721C - Min-Max Array Transformation |
1721A - Image | 1180C - Valeriy and Deque |
557A - Ilya and Diplomas | 1037D - Valid BFS |
1144F - Graph Without Long Directed Paths | 1228A - Distinct Digits |
355B - Vasya and Public Transport | 1230A - Dawid and Bags of Candies |
1530A - Binary Decimal | 1472D - Even-Odd Game |
441C - Valera and Tubes | 1328E - Tree Queries |
265A - Colorful Stones (Simplified Edition) | 296A - Yaroslav and Permutations |
967B - Watering System | 152A - Marks |
1398A - Bad Triangle | 137A - Postcards and photos |
1674D - A-B-C Sort | 334A - Candy Bags |
855A - Tom Riddle's Diary | 1417A - Copy-paste |
1038A - Equality | 1061A - Coins |