def resolve():

    import sys

    import itertools

    import numpy as np



    readline = sys.stdin.readline



    N = int(readline())

    lst = [list(map(int, readline().split())) for _ in [0] * N]



    dp = np.full((N, 3), -1, np.int32)

    for i in range(N):

        for a, b in itertools.permutations([0, 1, 2], 2):

            if a == b:

                continue

            if i == 0:

                dp[i][a] = lst[i][a]

            else:

                dp[i][a] = max(dp[i][a], dp[i - 1][b] + lst[i][a])

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



resolve()

#!/usr/bin/env python3

def main():

    import numpy as np



    N = int(eval(input()))

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



    dp = np.zeros((N, 3), dtype=np.int64)

    dp[0] = happiness[0]

    for i in range(1, N):

        for a, yesterday in enumerate(dp[i - 1]):

            for b, today in enumerate(happiness[i]):

                if a == b:

                    continue

                dp[i][b] = max(dp[i][b], yesterday + today)

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





if __name__ == '__main__':

    main()

def resolve():
    import sys
    import itertools
    import numpy as np

    readline = sys.stdin.readline
    N = int(readline())
    lst = [list(map(int, readline().split())) for _ in [0] * N]
    dp = np.full((N, 3), -1, np.int32)
    for i in range(N):
        for a, b in itertools.permutations([0, 1, 2], 2):
            if a == b:
                continue
            if i == 0:
                dp[i][a] = lst[i][a]
            else:
                dp[i][a] = max(dp[i][a], dp[i - 1][b] + lst[i][a])
    print((max(dp[-1])))


resolve()

#!/usr/bin/env python3
def main():
    import numpy as np

    N = int(eval(input()))
    happiness = [list(map(int, input().split())) for _ in range(N)]
    dp = np.zeros((N, 3), dtype=np.int64)
    dp[0] = happiness[0]
    for i in range(1, N):
        for a, yesterday in enumerate(dp[i - 1]):
            for b, today in enumerate(happiness[i]):
                if a == b:
                    continue
                dp[i][b] = max(dp[i][b], yesterday + today)
    print((max(dp[-1])))


if __name__ == "__main__":
    main()

-def resolve(): -    import sys -    import itertools +#!/usr/bin/env python3 +def main(): -    readline = sys.stdin.readline -    N = int(readline()) -    lst = [list(map(int, readline().split())) for _ in [0] * N] -    dp = np.full((N, 3), -1, np.int32) -    for i in range(N): -        for a, b in itertools.permutations([0, 1, 2], 2): -            if a == b: -                continue -            if i == 0: -                dp[i][a] = lst[i][a] -            else: -                dp[i][a] = max(dp[i][a], dp[i - 1][b] + lst[i][a]) +    N = int(eval(input())) +    happiness = [list(map(int, input().split())) for _ in range(N)] +    dp = np.zeros((N, 3), dtype=np.int64) +    dp[0] = happiness[0] +    for i in range(1, N): +        for a, yesterday in enumerate(dp[i - 1]): +            for b, today in enumerate(happiness[i]): +                if a == b: +                    continue +                dp[i][b] = max(dp[i][b], yesterday + today) -resolve() +if __name__ == "__main__": +    main()