def resolve():

	n = int(eval(input()))

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

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

		r = list(map(int, input().split()))

		for j in range(3):

			for k in range(3):

				if j == k:

					continue

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

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

resolve()
def resolve():

	n = int(eval(input()))

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

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

		nums = list(map(int, input().split()))

		for j in range(3):

			for k in range(3):

				if j == k:

					continue

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

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

resolve()
def resolve():
    n = int(eval(input()))
    dp = [[0] * 3 for _ in range(n + 1)]
    for i in range(1, n + 1):
        r = list(map(int, input().split()))
        for j in range(3):
            for k in range(3):
                if j == k:
                    continue
                dp[i][j] = max(dp[i][j], dp[i - 1][k] + r[j])
    print((max(dp[-1])))


resolve()

def resolve():
    n = int(eval(input()))
    dp = [[0] * 3 for _ in range(n + 1)]
    for i in range(1, n + 1):
        nums = list(map(int, input().split()))
        for j in range(3):
            for k in range(3):
                if j == k:
                    continue
                dp[i][j] = max(dp[i][j], nums[j] + dp[i - 1][k])
    print((max(dp[-1])))


resolve()

-        r = list(map(int, input().split())) +        nums = list(map(int, input().split())) -                dp[i][j] = max(dp[i][j], dp[i - 1][k] + r[j]) +                dp[i][j] = max(dp[i][j], nums[j] + dp[i - 1][k])