

n = int(eval(input()))



a = [[int(i) for i in input().split()] for j in range(n)]



def happy(n, a):

    d = [[0] * 3 for j in range(n)]

    for i in range(3):

        d[0][i] = a[0][i]



    for i in range(1, n):

        d[i][0] = max(d[i - 1][1], d[i - 1][2]) + a[i][0]

        d[i][1] = max(d[i - 1][0], d[i - 1][2]) + a[i][1]

        d[i][2] = max(d[i - 1][0], d[i - 1][1]) + a[i][2]



    return max(d[n - 1])



print((happy(n, a)))

import sys

input = sys.stdin.readline



n = int(eval(input()))



abc = [[int(i) for i in input().split()] for j in range(n)]



def happy(n, abc):

    da, db, dc = 0, 0, 0

    for a, b, c in abc:

        na = max(db, dc) + a

        nb = max(dc, da) + b

        nc = max(da, db) + c

        da, db, dc = na, nb, nc



    return max(da, db, dc)



print((happy(n, abc)))

n = int(eval(input()))
a = [[int(i) for i in input().split()] for j in range(n)]


def happy(n, a):
    d = [[0] * 3 for j in range(n)]
    for i in range(3):
        d[0][i] = a[0][i]
    for i in range(1, n):
        d[i][0] = max(d[i - 1][1], d[i - 1][2]) + a[i][0]
        d[i][1] = max(d[i - 1][0], d[i - 1][2]) + a[i][1]
        d[i][2] = max(d[i - 1][0], d[i - 1][1]) + a[i][2]
    return max(d[n - 1])


print((happy(n, a)))

import sys

input = sys.stdin.readline
n = int(eval(input()))
abc = [[int(i) for i in input().split()] for j in range(n)]


def happy(n, abc):
    da, db, dc = 0, 0, 0
    for a, b, c in abc:
        na = max(db, dc) + a
        nb = max(dc, da) + b
        nc = max(da, db) + c
        da, db, dc = na, nb, nc
    return max(da, db, dc)


print((happy(n, abc)))

+import sys + +input = sys.stdin.readline -a = [[int(i) for i in input().split()] for j in range(n)] +abc = [[int(i) for i in input().split()] for j in range(n)] -def happy(n, a): -    d = [[0] * 3 for j in range(n)] -    for i in range(3): -        d[0][i] = a[0][i] -    for i in range(1, n): -        d[i][0] = max(d[i - 1][1], d[i - 1][2]) + a[i][0] -        d[i][1] = max(d[i - 1][0], d[i - 1][2]) + a[i][1] -        d[i][2] = max(d[i - 1][0], d[i - 1][1]) + a[i][2] -    return max(d[n - 1]) +def happy(n, abc): +    da, db, dc = 0, 0, 0 +    for a, b, c in abc: +        na = max(db, dc) + a +        nb = max(dc, da) + b +        nc = max(da, db) + c +        da, db, dc = na, nb, nc +    return max(da, db, dc) -print((happy(n, a))) +print((happy(n, abc)))