# coding: utf-8

# Your code here!

N=int(eval(input()))

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



if N==1:

    print((max(list(map(int,input().split())))))

else:

    for i in range(0,N):

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

        if i==0:

            dp[0]=l

        else:

            for j in range(3):

                index_l=[0,1,2]

                index_l.pop(j)

                for index in index_l:

                    #print(i,j,int(index))

                    dp[i][index]=max(dp[i-1][j]+l[index],dp[i][index])



    print((max(dp[N-1])))
# coding: utf-8

# Your code here!

N=int(eval(input()))

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

A,B,C=list(map(int,input().split()))

l[0][0]=A

l[0][1]=B

l[0][2]=C





for i in range(1,N):

    A,B,C=list(map(int,input().split()))

    l[i][0]=A+(max(l[i-1][1],l[i-1][2]))

    l[i][1]=B+(max(l[i-1][0],l[i-1][2]))

    l[i][2]=C+(max(l[i-1][1],l[i-1][0]))



print((max(l[-1])))

# coding: utf-8
# Your code here!
N = int(eval(input()))
dp = [[0] * 3 for i in range(N)]
if N == 1:
    print((max(list(map(int, input().split())))))
else:
    for i in range(0, N):
        l = list(map(int, input().split()))
        if i == 0:
            dp[0] = l
        else:
            for j in range(3):
                index_l = [0, 1, 2]
                index_l.pop(j)
                for index in index_l:
                    # print(i,j,int(index))
                    dp[i][index] = max(dp[i - 1][j] + l[index], dp[i][index])
    print((max(dp[N - 1])))

# coding: utf-8
# Your code here!
N = int(eval(input()))
l = [[0] * 3 for i in range(N)]
A, B, C = list(map(int, input().split()))
l[0][0] = A
l[0][1] = B
l[0][2] = C
for i in range(1, N):
    A, B, C = list(map(int, input().split()))
    l[i][0] = A + (max(l[i - 1][1], l[i - 1][2]))
    l[i][1] = B + (max(l[i - 1][0], l[i - 1][2]))
    l[i][2] = C + (max(l[i - 1][1], l[i - 1][0]))
print((max(l[-1])))

-dp = [[0] * 3 for i in range(N)] -if N == 1: -    print((max(list(map(int, input().split()))))) -else: -    for i in range(0, N): -        l = list(map(int, input().split())) -        if i == 0: -            dp[0] = l -        else: -            for j in range(3): -                index_l = [0, 1, 2] -                index_l.pop(j) -                for index in index_l: -                    # print(i,j,int(index)) -                    dp[i][index] = max(dp[i - 1][j] + l[index], dp[i][index]) -    print((max(dp[N - 1]))) +l = [[0] * 3 for i in range(N)] +A, B, C = list(map(int, input().split())) +l[0][0] = A +l[0][1] = B +l[0][2] = C +for i in range(1, N): +    A, B, C = list(map(int, input().split())) +    l[i][0] = A + (max(l[i - 1][1], l[i - 1][2])) +    l[i][1] = B + (max(l[i - 1][0], l[i - 1][2])) +    l[i][2] = C + (max(l[i - 1][1], l[i - 1][0])) +print((max(l[-1])))