n = int(eval(input()))

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



dp = [[0] * 3 for _ in range(n)]

dp[0][0] = abc[0][0]

dp[0][1] = abc[0][1]

dp[0][2] = abc[0][2]



for i in range(1, n):

    for j in range(3):

        for k in range(3):

            if j != k:

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



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

import sys

input = sys.stdin.readline



def main():

    N = int(eval(input()))

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

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

    for i in range(3):

        dp[0][i] = 0

    for i in range(1, N+1):

        for today in range(3):

            for yesterday in range(3):

                if today == yesterday:

                    continue

                dp[i][today] = max(dp[i][today], dp[i-1][yesterday] + abc[i-1][today])

    ans = 0

    for i in range(3):

        ans = max(ans, dp[N][i])

    print(ans)

if __name__ == '__main__':

    main()
n = int(eval(input()))
abc = [tuple(map(int, input().split())) for _ in range(n)]
dp = [[0] * 3 for _ in range(n)]
dp[0][0] = abc[0][0]
dp[0][1] = abc[0][1]
dp[0][2] = abc[0][2]
for i in range(1, n):
    for j in range(3):
        for k in range(3):
            if j != k:
                dp[i][j] = max(dp[i][j], dp[i - 1][k] + abc[i][j])
print((max(dp[n - 1])))

import sys

input = sys.stdin.readline


def main():
    N = int(eval(input()))
    abc = [tuple(map(int, input().split())) for _ in range(N)]
    dp = [[0] * 3 for _ in range(N + 1)]
    for i in range(3):
        dp[0][i] = 0
    for i in range(1, N + 1):
        for today in range(3):
            for yesterday in range(3):
                if today == yesterday:
                    continue
                dp[i][today] = max(
                    dp[i][today], dp[i - 1][yesterday] + abc[i - 1][today]
                )
    ans = 0
    for i in range(3):
        ans = max(ans, dp[N][i])
    print(ans)


if __name__ == "__main__":
    main()

-n = int(eval(input())) -abc = [tuple(map(int, input().split())) for _ in range(n)] -dp = [[0] * 3 for _ in range(n)] -dp[0][0] = abc[0][0] -dp[0][1] = abc[0][1] -dp[0][2] = abc[0][2] -for i in range(1, n): -    for j in range(3): -        for k in range(3): -            if j != k: -                dp[i][j] = max(dp[i][j], dp[i - 1][k] + abc[i][j]) -print((max(dp[n - 1]))) +import sys + +input = sys.stdin.readline + + +def main(): +    N = int(eval(input())) +    abc = [tuple(map(int, input().split())) for _ in range(N)] +    dp = [[0] * 3 for _ in range(N + 1)] +    for i in range(3): +        dp[0][i] = 0 +    for i in range(1, N + 1): +        for today in range(3): +            for yesterday in range(3): +                if today == yesterday: +                    continue +                dp[i][today] = max( +                    dp[i][today], dp[i - 1][yesterday] + abc[i - 1][today] +                ) +    ans = 0 +    for i in range(3): +        ans = max(ans, dp[N][i]) +    print(ans) + + +if __name__ == "__main__": +    main()