# EduDPC - Vacation

import sys

input = sys.stdin.readline



n = int(eval(input()))

arr = [list(map(int, input().rstrip().split())) for _ in range(n)]

dp = [[0, 0, 0] for i in range(n)]

dp[0] = arr[0]

for i in range(1, n):

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

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

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

print((max(dp[-1])))
# dpC - Vacation

# 貰うDP

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):  # yesterday

            for k in range(3):  # today

                if j != k:

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

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





if __name__ == "__main__":

    main()
# EduDPC - Vacation
import sys

input = sys.stdin.readline
n = int(eval(input()))
arr = [list(map(int, input().rstrip().split())) for _ in range(n)]
dp = [[0, 0, 0] for i in range(n)]
dp[0] = arr[0]
for i in range(1, n):
    dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + arr[i][0]
    dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + arr[i][1]
    dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + arr[i][2]
print((max(dp[-1])))

# dpC - Vacation
# 貰うDP
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):  # yesterday
            for k in range(3):  # today
                if j != k:
                    dp[i][k] = max(dp[i][k], dp[i - 1][j] + A[i][k])
    print((max(dp[-1])))


if __name__ == "__main__":
    main()

-# EduDPC - Vacation +# dpC - Vacation +# 貰うDP -n = int(eval(input())) -arr = [list(map(int, input().rstrip().split())) for _ in range(n)] -dp = [[0, 0, 0] for i in range(n)] -dp[0] = arr[0] -for i in range(1, n): -    dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + arr[i][0] -    dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + arr[i][1] -    dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + arr[i][2] -print((max(dp[-1]))) + + +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):  # yesterday +            for k in range(3):  # today +                if j != k: +                    dp[i][k] = max(dp[i][k], dp[i - 1][j] + A[i][k]) +    print((max(dp[-1]))) + + +if __name__ == "__main__": +    main()