n = int(eval(input()))

dp = list(list(map(int, input().split())) for _ in range(n))

for i in range(1, n):

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

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

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

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

import sys

readline = sys.stdin.readline

n = int(eval(input()))

dp = list(list(map(int, readline().split())) for _ in range(n))

for i in range(1, n):

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

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

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

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

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

import sys

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

+import sys + +readline = sys.stdin.readline -dp = list(list(map(int, input().split())) for _ in range(n)) +dp = list(list(map(int, readline().split())) for _ in range(n))