# dpC

import sys

input = sys.stdin.readline



def main():

    n = int(eval(input()))

    A = tuple(tuple(map(int, input().rstrip().split())) for _ in range(n))

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

    dp[0] = A[0]

    for i in range(1, n):  # i-th day

        for j in range(3):  # today

            for k in range(3):  # yesterday

                if j != k:

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

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





if __name__ == "__main__":

    main()
# C - Vacation

def main():

    N, *ABC = list(map(int, open(0).read().split()))

    prev = ABC[:3]

    for a, b, c in zip(*[iter(ABC[3:])] * 3):

        cur = [0] * 3

        cur[0] = max(prev[1:]) + a

        cur[1] = max(prev[0], prev[2]) + b

        cur[2] = max(prev[:2]) + c

        prev = cur

    print((max(prev)))





if __name__ == "__main__":

    main()

# dpC
import sys

input = sys.stdin.readline


def main():
    n = int(eval(input()))
    A = tuple(tuple(map(int, input().rstrip().split())) for _ in range(n))
    dp = [[0] * 3 for _ in range(n)]
    dp[0] = A[0]
    for i in range(1, n):  # i-th day
        for j in range(3):  # today
            for k in range(3):  # yesterday
                if j != k:
                    dp[i][j] = max(dp[i][j], dp[i - 1][k] + A[i][j])
    print((max(dp[-1])))


if __name__ == "__main__":
    main()

# C - Vacation
def main():
    N, *ABC = list(map(int, open(0).read().split()))
    prev = ABC[:3]
    for a, b, c in zip(*[iter(ABC[3:])] * 3):
        cur = [0] * 3
        cur[0] = max(prev[1:]) + a
        cur[1] = max(prev[0], prev[2]) + b
        cur[2] = max(prev[:2]) + c
        prev = cur
    print((max(prev)))


if __name__ == "__main__":
    main()

-# dpC -import sys - -input = sys.stdin.readline - - +# C - Vacation -    n = int(eval(input())) -    A = tuple(tuple(map(int, input().rstrip().split())) for _ in range(n)) -    dp = [[0] * 3 for _ in range(n)] -    dp[0] = A[0] -    for i in range(1, n):  # i-th day -        for j in range(3):  # today -            for k in range(3):  # yesterday -                if j != k: -                    dp[i][j] = max(dp[i][j], dp[i - 1][k] + A[i][j]) -    print((max(dp[-1]))) +    N, *ABC = list(map(int, open(0).read().split())) +    prev = ABC[:3] +    for a, b, c in zip(*[iter(ABC[3:])] * 3): +        cur = [0] * 3 +        cur[0] = max(prev[1:]) + a +        cur[1] = max(prev[0], prev[2]) + b +        cur[2] = max(prev[:2]) + c +        prev = cur +    print((max(prev)))