N=int(eval(input()))

H=[[0,0,0]]+[ list(map(int, input().split())) for _ in range(N) ]



#print(N,H)



def chmax(dp, n, k, a):

	b = (dp[n][k]<a)

	if b: dp[n][k]=a

	return b





#dp=[[0,0,0,0,0,0] for _ in range(N+1)]

dp=[[0,0,0] for _ in range(N+1)]





for i in range(1,N+1):

	for j in range(3):

		for k in range(3):

			if j==k: continue

			chmax(dp,i,k, dp[i-1][j] + H[i][k])

	



print(( max(dp[N]) ))

INF  = float("inf") # 正の無限大



N = int(eval(input()))						# 5



A=[0]*N

B=[0]*N

C=[0]*N



for i in range(N):

	a,b,c = list(map(int, input().split()))		# 5 7 2

	A[i] = a

	B[i] = b

	C[i] = c





dp = [[0,0,0] for _ in range(N)]



for i in range(N):

	dp[i][0] = A[i] + (max(dp[i-1][1], dp[i-1][2]) if i>0 else 0)

	dp[i][1] = B[i] + (max(dp[i-1][2], dp[i-1][0]) if i>0 else 0)

	dp[i][2] = C[i] + (max(dp[i-1][0], dp[i-1][1]) if i>0 else 0)





print(( max(dp[-1][0], dp[-1][1], dp[-1][2]) ))



#print(dp)

N = int(eval(input()))
H = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(N)]
# print(N,H)
def chmax(dp, n, k, a):
    b = dp[n][k] < a
    if b:
        dp[n][k] = a
    return b


# dp=[[0,0,0,0,0,0] for _ in range(N+1)]
dp = [[0, 0, 0] for _ in range(N + 1)]
for i in range(1, N + 1):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            chmax(dp, i, k, dp[i - 1][j] + H[i][k])
print((max(dp[N])))

INF = float("inf")  # 正の無限大
N = int(eval(input()))  # 5
A = [0] * N
B = [0] * N
C = [0] * N
for i in range(N):
    a, b, c = list(map(int, input().split()))  # 5 7 2
    A[i] = a
    B[i] = b
    C[i] = c
dp = [[0, 0, 0] for _ in range(N)]
for i in range(N):
    dp[i][0] = A[i] + (max(dp[i - 1][1], dp[i - 1][2]) if i > 0 else 0)
    dp[i][1] = B[i] + (max(dp[i - 1][2], dp[i - 1][0]) if i > 0 else 0)
    dp[i][2] = C[i] + (max(dp[i - 1][0], dp[i - 1][1]) if i > 0 else 0)
print((max(dp[-1][0], dp[-1][1], dp[-1][2])))
# print(dp)

-N = int(eval(input())) -H = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(N)] -# print(N,H) -def chmax(dp, n, k, a): -    b = dp[n][k] < a -    if b: -        dp[n][k] = a -    return b - - -# dp=[[0,0,0,0,0,0] for _ in range(N+1)] -dp = [[0, 0, 0] for _ in range(N + 1)] -for i in range(1, N + 1): -    for j in range(3): -        for k in range(3): -            if j == k: -                continue -            chmax(dp, i, k, dp[i - 1][j] + H[i][k]) -print((max(dp[N]))) +INF = float("inf")  # 正の無限大 +N = int(eval(input()))  # 5 +A = [0] * N +B = [0] * N +C = [0] * N +for i in range(N): +    a, b, c = list(map(int, input().split()))  # 5 7 2 +    A[i] = a +    B[i] = b +    C[i] = c +dp = [[0, 0, 0] for _ in range(N)] +for i in range(N): +    dp[i][0] = A[i] + (max(dp[i - 1][1], dp[i - 1][2]) if i > 0 else 0) +    dp[i][1] = B[i] + (max(dp[i - 1][2], dp[i - 1][0]) if i > 0 else 0) +    dp[i][2] = C[i] + (max(dp[i - 1][0], dp[i - 1][1]) if i > 0 else 0) +print((max(dp[-1][0], dp[-1][1], dp[-1][2]))) +# print(dp)