import numpy as np

n=int(eval(input()))

abc=[]

for _ in range(n):

      abc.append(list(map(int,input().split())))

dp=np.zeros((n+1,3),np.int64)

# dp[i][0]:i日目でaをとった時の最大。dp[0]=[0,0,0]。求めるのはmax(dp[n])

dp[1]=np.array(abc[0])

for i in range(2,n+1):

      dp[i][0]=abc[i-1][0]+max(dp[i-1][1],dp[i-1][2])

      dp[i][1]=abc[i-1][1]+max(dp[i-1][0],dp[i-1][2])

      dp[i][2]=abc[i-1][2]+max(dp[i-1][0],dp[i-1][1])



print((int(np.max(dp[-1]))))

import numpy as np

n=int(eval(input()))

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

dp=np.zeros((n+1,3),np.int64)

# dp[i+1][j]:i日目にjで遊んだ時の最大の幸福度

# dp[0][j]=0,dp[1][j]=abc[0][j]

dp[1]=abc[0]

for i in range(1,n):

      dp[i+1][0]=abc[i][0]+max(dp[i][1],dp[i][2])

      dp[i+1][1]=abc[i][1]+max(dp[i][0],dp[i][2])

      dp[i+1][2]=abc[i][2]+max(dp[i][0],dp[i][1])

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

n = int(eval(input()))
abc = []
for _ in range(n):
    abc.append(list(map(int, input().split())))
dp = np.zeros((n + 1, 3), np.int64)
# dp[i][0]:i日目でaをとった時の最大。dp[0]=[0,0,0]。求めるのはmax(dp[n])
dp[1] = np.array(abc[0])
for i in range(2, n + 1):
    dp[i][0] = abc[i - 1][0] + max(dp[i - 1][1], dp[i - 1][2])
    dp[i][1] = abc[i - 1][1] + max(dp[i - 1][0], dp[i - 1][2])
    dp[i][2] = abc[i - 1][2] + max(dp[i - 1][0], dp[i - 1][1])
print((int(np.max(dp[-1]))))

import numpy as np

n = int(eval(input()))
abc = np.array([list(map(int, input().split())) for _ in range(n)])
dp = np.zeros((n + 1, 3), np.int64)
# dp[i+1][j]:i日目にjで遊んだ時の最大の幸福度
# dp[0][j]=0,dp[1][j]=abc[0][j]
dp[1] = abc[0]
for i in range(1, n):
    dp[i + 1][0] = abc[i][0] + max(dp[i][1], dp[i][2])
    dp[i + 1][1] = abc[i][1] + max(dp[i][0], dp[i][2])
    dp[i + 1][2] = abc[i][2] + max(dp[i][0], dp[i][1])
print((np.max(dp[-1])))

-abc = [] -for _ in range(n): -    abc.append(list(map(int, input().split()))) +abc = np.array([list(map(int, input().split())) for _ in range(n)]) -# dp[i][0]:i日目でaをとった時の最大。dp[0]=[0,0,0]。求めるのはmax(dp[n]) -dp[1] = np.array(abc[0]) -for i in range(2, n + 1): -    dp[i][0] = abc[i - 1][0] + max(dp[i - 1][1], dp[i - 1][2]) -    dp[i][1] = abc[i - 1][1] + max(dp[i - 1][0], dp[i - 1][2]) -    dp[i][2] = abc[i - 1][2] + max(dp[i - 1][0], dp[i - 1][1]) -print((int(np.max(dp[-1])))) +# dp[i+1][j]:i日目にjで遊んだ時の最大の幸福度 +# dp[0][j]=0,dp[1][j]=abc[0][j] +dp[1] = abc[0] +for i in range(1, n): +    dp[i + 1][0] = abc[i][0] + max(dp[i][1], dp[i][2]) +    dp[i + 1][1] = abc[i][1] + max(dp[i][0], dp[i][2]) +    dp[i + 1][2] = abc[i][2] + max(dp[i][0], dp[i][1]) +print((np.max(dp[-1])))