#S = [[0 for j in range(3)] for i in range(2)]　2行3列の場合

S = [[0 for j in range(3)] for i in range(100010)]





DP= [[0 for j in range(3)] for i in range(100010)]



N=int(eval(input()))



for i in range(N):

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

    for j in range(len(L)):

        S[i][j]=L[j]



for i in range(N):

    for j in range(3):

        for k in range(3):

            if j==k:

                pass

            else:

                if DP[i+1][k]<DP[i][j]+S[i][k]:

                    DP[i+1][k]=DP[i][j]+S[i][k]



ans=0

for j in range(3):

    if ans<DP[N][j]:

        ans=DP[N][j]

print(ans)
N=int(eval(input()))

#S = [[0 for j in range(3)] for i in range(2)]　2行3列の場合

S = [[0 for j in range(3)] for i in range(100010)]



            

def chmax(a,b):

    if a>b:

        return a

    else:

        return b



for i in range(N):

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

    S[i+1][0]=A

    S[i+1][1]=B

    S[i+1][2]=C



DP=[[0 for j in range(3)] for i in range(100010)]



DP[0][0]=0

DP[0][1]=0

DP[0][2]=0

DP[1][0]=S[1][0]

DP[1][1]=S[1][1]

DP[1][2]=S[1][2]



if N==1:

    print((max(DP[1])))

    exit()



for k in range(2,N+1):

    for i in range(3):

        for j in range(3):

            if i!=j:

                DP[k][i]=chmax(DP[k-1][j]+S[k][i],DP[k][i])

                DP[k][j]=chmax(DP[k-1][i]+S[k][j],DP[k][j])

print((max(DP[N])))





# S = [[0 for j in range(3)] for i in range(2)]　2行3列の場合
S = [[0 for j in range(3)] for i in range(100010)]
DP = [[0 for j in range(3)] for i in range(100010)]
N = int(eval(input()))
for i in range(N):
    L = list(map(int, input().split()))
    for j in range(len(L)):
        S[i][j] = L[j]
for i in range(N):
    for j in range(3):
        for k in range(3):
            if j == k:
                pass
            else:
                if DP[i + 1][k] < DP[i][j] + S[i][k]:
                    DP[i + 1][k] = DP[i][j] + S[i][k]
ans = 0
for j in range(3):
    if ans < DP[N][j]:
        ans = DP[N][j]
print(ans)

N = int(eval(input()))
# S = [[0 for j in range(3)] for i in range(2)]　2行3列の場合
S = [[0 for j in range(3)] for i in range(100010)]


def chmax(a, b):
    if a > b:
        return a
    else:
        return b


for i in range(N):
    A, B, C = list(map(int, input().split()))
    S[i + 1][0] = A
    S[i + 1][1] = B
    S[i + 1][2] = C
DP = [[0 for j in range(3)] for i in range(100010)]
DP[0][0] = 0
DP[0][1] = 0
DP[0][2] = 0
DP[1][0] = S[1][0]
DP[1][1] = S[1][1]
DP[1][2] = S[1][2]
if N == 1:
    print((max(DP[1])))
    exit()
for k in range(2, N + 1):
    for i in range(3):
        for j in range(3):
            if i != j:
                DP[k][i] = chmax(DP[k - 1][j] + S[k][i], DP[k][i])
                DP[k][j] = chmax(DP[k - 1][i] + S[k][j], DP[k][j])
print((max(DP[N])))

+N = int(eval(input())) + + +def chmax(a, b): +    if a > b: +        return a +    else: +        return b + + +for i in range(N): +    A, B, C = list(map(int, input().split())) +    S[i + 1][0] = A +    S[i + 1][1] = B +    S[i + 1][2] = C -N = int(eval(input())) -for i in range(N): -    L = list(map(int, input().split())) -    for j in range(len(L)): -        S[i][j] = L[j] -for i in range(N): -    for j in range(3): -        for k in range(3): -            if j == k: -                pass -            else: -                if DP[i + 1][k] < DP[i][j] + S[i][k]: -                    DP[i + 1][k] = DP[i][j] + S[i][k] -ans = 0 -for j in range(3): -    if ans < DP[N][j]: -        ans = DP[N][j] -print(ans) +DP[0][0] = 0 +DP[0][1] = 0 +DP[0][2] = 0 +DP[1][0] = S[1][0] +DP[1][1] = S[1][1] +DP[1][2] = S[1][2] +if N == 1: +    print((max(DP[1]))) +    exit() +for k in range(2, N + 1): +    for i in range(3): +        for j in range(3): +            if i != j: +                DP[k][i] = chmax(DP[k - 1][j] + S[k][i], DP[k][i]) +                DP[k][j] = chmax(DP[k - 1][i] + S[k][j], DP[k][j]) +print((max(DP[N])))