def main():

    N = int(eval(input()))

    work = []

    for _ in range(N):

        a, b, c = list(map(int, input().split()))

        work.append((a,b,c))

    

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

    for i in range(N):

        for j in range(3):

            if i == 0:

                dp[i][j] = work[i][j]

                continue

            if j == 0:

                dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + work[i][0]

            elif j == 1:

                dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + work[i][1]

            elif j == 2:

                dp[i][2] = max(dp[i-1][1], dp[i-1][0]) + work[i][2]



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

    



if __name__ == "__main__":

    main()
def main():

    N = int(eval(input()))

    acts = []

    for _ in range(N):

        a, b, c = list(map(int, input().split()))

        acts.append([a,b,c])

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



    dp[0][0] = acts[0][0]

    dp[0][1] = acts[0][1]

    dp[0][2] = acts[0][2]

    for i in range(1,N):

        for j in range(3):

            if j == 0:

                score = max(dp[i-1][1], dp[i-1][2])

            if j == 1:

                score = max(dp[i-1][0], dp[i-1][2])

            if j == 2:

                score = max(dp[i-1][1], dp[i-1][0])

            dp[i][j] = acts[i][j] + score



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







if __name__ == "__main__":

    main()
def main():
    N = int(eval(input()))
    work = []
    for _ in range(N):
        a, b, c = list(map(int, input().split()))
        work.append((a, b, c))
    dp = [[0] * 3 for _ in range(N)]
    for i in range(N):
        for j in range(3):
            if i == 0:
                dp[i][j] = work[i][j]
                continue
            if j == 0:
                dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + work[i][0]
            elif j == 1:
                dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + work[i][1]
            elif j == 2:
                dp[i][2] = max(dp[i - 1][1], dp[i - 1][0]) + work[i][2]
    print((max(dp[N - 1])))


if __name__ == "__main__":
    main()

def main():
    N = int(eval(input()))
    acts = []
    for _ in range(N):
        a, b, c = list(map(int, input().split()))
        acts.append([a, b, c])
    dp = [[0] * 3 for _ in range(N + 5)]
    dp[0][0] = acts[0][0]
    dp[0][1] = acts[0][1]
    dp[0][2] = acts[0][2]
    for i in range(1, N):
        for j in range(3):
            if j == 0:
                score = max(dp[i - 1][1], dp[i - 1][2])
            if j == 1:
                score = max(dp[i - 1][0], dp[i - 1][2])
            if j == 2:
                score = max(dp[i - 1][1], dp[i - 1][0])
            dp[i][j] = acts[i][j] + score
    print((max(dp[N - 1])))


if __name__ == "__main__":
    main()

-    work = [] +    acts = [] -        work.append((a, b, c)) -    dp = [[0] * 3 for _ in range(N)] -    for i in range(N): +        acts.append([a, b, c]) +    dp = [[0] * 3 for _ in range(N + 5)] +    dp[0][0] = acts[0][0] +    dp[0][1] = acts[0][1] +    dp[0][2] = acts[0][2] +    for i in range(1, N): -            if i == 0: -                dp[i][j] = work[i][j] -                continue -                dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + work[i][0] -            elif j == 1: -                dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + work[i][1] -            elif j == 2: -                dp[i][2] = max(dp[i - 1][1], dp[i - 1][0]) + work[i][2] +                score = max(dp[i - 1][1], dp[i - 1][2]) +            if j == 1: +                score = max(dp[i - 1][0], dp[i - 1][2]) +            if j == 2: +                score = max(dp[i - 1][1], dp[i - 1][0]) +            dp[i][j] = acts[i][j] + score