import numpy as np

n=int(eval(input()))

ABC=[list(map(int,input().split())) for _ in range(n)]



dp=np.zeros((n,3),int)

for i in range(3):

  dp[0][i]=ABC[0][i]

for i in range(n-1):

  for j in range(3):

    dp[i+1][j]=max(dp[i][(j+1)%3]+ABC[i+1][j], dp[i][(j+2)%3]+ABC[i+1][j])

print((max(dp[-1])))
import numpy as np

n=int(eval(input()))

ABC=[list(map(int,input().split())) for _ in range(n)]



dp=np.zeros((n,3),int)

for i in range(3):

  dp[0,i]=ABC[0][i]

for i in range(1,n):

  for j in range(3):

    dp[i,j]=max(dp[i-1,(j+1)%3]+ABC[i][j],dp[i-1,(j+2)%3]+ABC[i][j])

print((max(dp[-1])))
import numpy as np

n = int(eval(input()))
ABC = [list(map(int, input().split())) for _ in range(n)]
dp = np.zeros((n, 3), int)
for i in range(3):
    dp[0][i] = ABC[0][i]
for i in range(n - 1):
    for j in range(3):
        dp[i + 1][j] = max(
            dp[i][(j + 1) % 3] + ABC[i + 1][j], dp[i][(j + 2) % 3] + ABC[i + 1][j]
        )
print((max(dp[-1])))

import numpy as np

n = int(eval(input()))
ABC = [list(map(int, input().split())) for _ in range(n)]
dp = np.zeros((n, 3), int)
for i in range(3):
    dp[0, i] = ABC[0][i]
for i in range(1, n):
    for j in range(3):
        dp[i, j] = max(
            dp[i - 1, (j + 1) % 3] + ABC[i][j], dp[i - 1, (j + 2) % 3] + ABC[i][j]
        )
print((max(dp[-1])))

-    dp[0][i] = ABC[0][i] -for i in range(n - 1): +    dp[0, i] = ABC[0][i] +for i in range(1, n): -        dp[i + 1][j] = max( -            dp[i][(j + 1) % 3] + ABC[i + 1][j], dp[i][(j + 2) % 3] + ABC[i + 1][j] +        dp[i, j] = max( +            dp[i - 1, (j + 1) % 3] + ABC[i][j], dp[i - 1, (j + 2) % 3] + ABC[i][j]