N=int(eval(input()))

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

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

for i in range(N):

    for j in range(3): #移動元

        for k in range(3): #移動先

            if j==k: continue

            dp[i+1][k] = max(dp[i+1][k], dp[i][j]+abc[i][k])

print((max(dp[N])))
def main():

    N=int(eval(input()))

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

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

    for i in range(N):

        for j in range(3): #移動元

            for k in range(3): #移動先

                if j==k: continue

                dp[i+1][k] = max(dp[i+1][k], dp[i][j]+abc[i][k])

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

    

if __name__ == '__main__':

    main()
N = int(eval(input()))
dp = [[0] * 3 for _ in range(N + 1)]
abc = [list(map(int, input().split())) for _ in range(N)]
for i in range(N):
    for j in range(3):  # 移動元
        for k in range(3):  # 移動先
            if j == k:
                continue
            dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + abc[i][k])
print((max(dp[N])))

def main():
    N = int(eval(input()))
    dp = [[0] * 3 for _ in range(N + 1)]
    abc = [list(map(int, input().split())) for _ in range(N)]
    for i in range(N):
        for j in range(3):  # 移動元
            for k in range(3):  # 移動先
                if j == k:
                    continue
                dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + abc[i][k])
    print((max(dp[N])))


if __name__ == "__main__":
    main()

-N = int(eval(input())) -dp = [[0] * 3 for _ in range(N + 1)] -abc = [list(map(int, input().split())) for _ in range(N)] -for i in range(N): -    for j in range(3):  # 移動元 -        for k in range(3):  # 移動先 -            if j == k: -                continue -            dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + abc[i][k]) -print((max(dp[N]))) +def main(): +    N = int(eval(input())) +    dp = [[0] * 3 for _ in range(N + 1)] +    abc = [list(map(int, input().split())) for _ in range(N)] +    for i in range(N): +        for j in range(3):  # 移動元 +            for k in range(3):  # 移動先 +                if j == k: +                    continue +                dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + abc[i][k]) +    print((max(dp[N]))) + + +if __name__ == "__main__": +    main()