ac100
N=int(input())
for i in range(N):
abc=[int(j) for j in input().split()]
a,b,c=abc[0],abc[1],abc[2]
if i==0:
dpa,dpb=a c,b
else:
tmp=dpa
dpa=min(dpa a,dpb a c)
dpb=min(dpb b,tmp b c)
print(min(dpa,dpb))