n = int(eval(input()))



table = []

for _ in range(n):

    table.append([int(v) for v in input().split()])



dp = [0] * 3



for i in range(n):

    dp_n = [0] * 3



    a, b, c = table[i]



    a0 = dp[0]

    b0 = dp[1]

    c0 = dp[2]



    dp_n[0] = max(b0, c0) + a

    dp_n[1] = max(c0, a0) + b

    dp_n[2] = max(a0, b0) + c



    dp = dp_n



print((max(dp)))

def main():

    N = int(eval(input()))



    table = []

    for _ in range(N):

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

        table.append((a, b, c))



    dp = [0] * 3



    for i in range(N):

        a, b, c = table[i]



        a0 = dp[0]

        b0 = dp[1]

        c0 = dp[2]



        dp[0] = max(b0, c0) + a

        dp[1] = max(c0, a0) + b

        dp[2] = max(a0, b0) + c



    print((max(dp)))



main()

n = int(eval(input()))
table = []
for _ in range(n):
    table.append([int(v) for v in input().split()])
dp = [0] * 3
for i in range(n):
    dp_n = [0] * 3
    a, b, c = table[i]
    a0 = dp[0]
    b0 = dp[1]
    c0 = dp[2]
    dp_n[0] = max(b0, c0) + a
    dp_n[1] = max(c0, a0) + b
    dp_n[2] = max(a0, b0) + c
    dp = dp_n
print((max(dp)))

def main():
    N = int(eval(input()))
    table = []
    for _ in range(N):
        a, b, c = list(map(int, input().split()))
        table.append((a, b, c))
    dp = [0] * 3
    for i in range(N):
        a, b, c = table[i]
        a0 = dp[0]
        b0 = dp[1]
        c0 = dp[2]
        dp[0] = max(b0, c0) + a
        dp[1] = max(c0, a0) + b
        dp[2] = max(a0, b0) + c
    print((max(dp)))


main()

-n = int(eval(input())) -table = [] -for _ in range(n): -    table.append([int(v) for v in input().split()]) -dp = [0] * 3 -for i in range(n): -    dp_n = [0] * 3 -    a, b, c = table[i] -    a0 = dp[0] -    b0 = dp[1] -    c0 = dp[2] -    dp_n[0] = max(b0, c0) + a -    dp_n[1] = max(c0, a0) + b -    dp_n[2] = max(a0, b0) + c -    dp = dp_n -print((max(dp))) +def main(): +    N = int(eval(input())) +    table = [] +    for _ in range(N): +        a, b, c = list(map(int, input().split())) +        table.append((a, b, c)) +    dp = [0] * 3 +    for i in range(N): +        a, b, c = table[i] +        a0 = dp[0] +        b0 = dp[1] +        c0 = dp[2] +        dp[0] = max(b0, c0) + a +        dp[1] = max(c0, a0) + b +        dp[2] = max(a0, b0) + c +    print((max(dp))) + + +main()