n = int(eval(input()))

a,b,c = list(map(int,input().split()))

dp = [0,0,0] * n

dp[0] = [a,b,c]

for i in range(1,n):

    a,b,c = list(map(int,input().split()))

    dp[i] = [max(dp[i-1][1],dp[i-1][2])+a,max(dp[i-1][0],dp[i-1][2])+b,max(dp[i-1][0],dp[i-1][1])+c]



print((max(dp[n-1])))
import sys

input = sys.stdin.readline

n = int(eval(input()))

a = [0]*n

b = [0]*n

c = [0]*n

for i in range(n):

    a[i],b[i],c[i] = list(map(int,input().split()))



dpa = [a[0]]+[0]*(n-1)

dpb = [b[0]]+[0]*(n-1)

dpc = [c[0]]+[0]*(n-1)

for i in range(1,n):

    dpa[i] = max(dpb[i-1],dpc[i-1]) + a[i]

    dpb[i] = max(dpc[i-1],dpa[i-1]) + b[i]

    dpc[i] = max(dpa[i-1],dpb[i-1]) + c[i]

print((max(dpa[-1],dpb[-1],dpc[-1])))

n = int(eval(input()))
a, b, c = list(map(int, input().split()))
dp = [0, 0, 0] * n
dp[0] = [a, b, c]
for i in range(1, n):
    a, b, c = list(map(int, input().split()))
    dp[i] = [
        max(dp[i - 1][1], dp[i - 1][2]) + a,
        max(dp[i - 1][0], dp[i - 1][2]) + b,
        max(dp[i - 1][0], dp[i - 1][1]) + c,
    ]
print((max(dp[n - 1])))

import sys

input = sys.stdin.readline
n = int(eval(input()))
a = [0] * n
b = [0] * n
c = [0] * n
for i in range(n):
    a[i], b[i], c[i] = list(map(int, input().split()))
dpa = [a[0]] + [0] * (n - 1)
dpb = [b[0]] + [0] * (n - 1)
dpc = [c[0]] + [0] * (n - 1)
for i in range(1, n):
    dpa[i] = max(dpb[i - 1], dpc[i - 1]) + a[i]
    dpb[i] = max(dpc[i - 1], dpa[i - 1]) + b[i]
    dpc[i] = max(dpa[i - 1], dpb[i - 1]) + c[i]
print((max(dpa[-1], dpb[-1], dpc[-1])))

+import sys + +input = sys.stdin.readline -a, b, c = list(map(int, input().split())) -dp = [0, 0, 0] * n -dp[0] = [a, b, c] +a = [0] * n +b = [0] * n +c = [0] * n +for i in range(n): +    a[i], b[i], c[i] = list(map(int, input().split())) +dpa = [a[0]] + [0] * (n - 1) +dpb = [b[0]] + [0] * (n - 1) +dpc = [c[0]] + [0] * (n - 1) -    a, b, c = list(map(int, input().split())) -    dp[i] = [ -        max(dp[i - 1][1], dp[i - 1][2]) + a, -        max(dp[i - 1][0], dp[i - 1][2]) + b, -        max(dp[i - 1][0], dp[i - 1][1]) + c, -    ] -print((max(dp[n - 1]))) +    dpa[i] = max(dpb[i - 1], dpc[i - 1]) + a[i] +    dpb[i] = max(dpc[i - 1], dpa[i - 1]) + b[i] +    dpc[i] = max(dpa[i - 1], dpb[i - 1]) + c[i] +print((max(dpa[-1], dpb[-1], dpc[-1])))