N=int(eval(input()))

li=[list(map(int,input().split())) for i in range(N)]

dp=[[0]*3 for i in range(N)]

for i in range(N):

    if i==0:

        for j in range(3):

            dp[i][j] = li[i][j]

    else:

        for j in range(3):

            if j == 0:

                dp[i][j] = li[i][0] + dp[i-1][1] if dp[i-1][1] >= dp[i-1][2] else li[i][0] + dp[i-1][2]

            if j == 1:

                dp[i][j] = li[i][1] + dp[i-1][0] if dp[i-1][0] >= dp[i-1][2] else li[i][1] + dp[i-1][2]

            if j == 2:

                dp[i][j] = li[i][2] + dp[i-1][0] if dp[i-1][0] >= dp[i-1][1] else li[i][2] + dp[i-1][1]

print((max(dp[N-1])))

import sys

sys.setrecursionlimit(10**9)

INF=10**18

MOD=10**9+7

def input(): return sys.stdin.readline().rstrip()



def main():

    N=int(eval(input()))

    l=[]

    for i in range(N):

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

    dp=[[0]*3 for _ in range(N+1)]

    for i in range(N):

        for k in range(3):

            dp[i+1][k]=max(dp[i][(k+1)%3]+l[i][k],dp[i][(k+2)%3]+l[i][k])

    print((max(dp[N])))



if __name__ == '__main__':

    main()

N = int(eval(input()))
li = [list(map(int, input().split())) for i in range(N)]
dp = [[0] * 3 for i in range(N)]
for i in range(N):
    if i == 0:
        for j in range(3):
            dp[i][j] = li[i][j]
    else:
        for j in range(3):
            if j == 0:
                dp[i][j] = (
                    li[i][0] + dp[i - 1][1]
                    if dp[i - 1][1] >= dp[i - 1][2]
                    else li[i][0] + dp[i - 1][2]
                )
            if j == 1:
                dp[i][j] = (
                    li[i][1] + dp[i - 1][0]
                    if dp[i - 1][0] >= dp[i - 1][2]
                    else li[i][1] + dp[i - 1][2]
                )
            if j == 2:
                dp[i][j] = (
                    li[i][2] + dp[i - 1][0]
                    if dp[i - 1][0] >= dp[i - 1][1]
                    else li[i][2] + dp[i - 1][1]
                )
print((max(dp[N - 1])))

import sys

sys.setrecursionlimit(10**9)
INF = 10**18
MOD = 10**9 + 7


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(eval(input()))
    l = []
    for i in range(N):
        l.append(list(map(int, input().split())))
    dp = [[0] * 3 for _ in range(N + 1)]
    for i in range(N):
        for k in range(3):
            dp[i + 1][k] = max(
                dp[i][(k + 1) % 3] + l[i][k], dp[i][(k + 2) % 3] + l[i][k]
            )
    print((max(dp[N])))


if __name__ == "__main__":
    main()

-N = int(eval(input())) -li = [list(map(int, input().split())) for i in range(N)] -dp = [[0] * 3 for i in range(N)] -for i in range(N): -    if i == 0: -        for j in range(3): -            dp[i][j] = li[i][j] -    else: -        for j in range(3): -            if j == 0: -                dp[i][j] = ( -                    li[i][0] + dp[i - 1][1] -                    if dp[i - 1][1] >= dp[i - 1][2] -                    else li[i][0] + dp[i - 1][2] -                ) -            if j == 1: -                dp[i][j] = ( -                    li[i][1] + dp[i - 1][0] -                    if dp[i - 1][0] >= dp[i - 1][2] -                    else li[i][1] + dp[i - 1][2] -                ) -            if j == 2: -                dp[i][j] = ( -                    li[i][2] + dp[i - 1][0] -                    if dp[i - 1][0] >= dp[i - 1][1] -                    else li[i][2] + dp[i - 1][1] -                ) -print((max(dp[N - 1]))) +import sys + +sys.setrecursionlimit(10**9) +INF = 10**18 +MOD = 10**9 + 7 + + +def input(): +    return sys.stdin.readline().rstrip() + + +def main(): +    N = int(eval(input())) +    l = [] +    for i in range(N): +        l.append(list(map(int, input().split()))) +    dp = [[0] * 3 for _ in range(N + 1)] +    for i in range(N): +        for k in range(3): +            dp[i + 1][k] = max( +                dp[i][(k + 1) % 3] + l[i][k], dp[i][(k + 2) % 3] + l[i][k] +            ) +    print((max(dp[N]))) + + +if __name__ == "__main__": +    main()