import sys

input = sys.stdin.readline

sys.setrecursionlimit(10 ** 7)



N = int(eval(input()))

x,y,z = 0,0,0 # 最後に特定アクションを行った場合の最大幸福度

for _ in range(N):

    a,b,c = list(map(int,input().split()))

    x,y,z = max(y,z) + a, max(x,z) + b, max(x,y) + c

answer = max(x,y,z)

print(answer)
import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines



N = int(readline())

m = list(map(int,read().split()))

ABC = list(zip(m,m,m))



x,y,z = 0,0,0 # 最後の活動 -> 幸福度のmax

for a,b,c in ABC:

    x,y,z = max(y,z)+a,max(x,z)+b,max(x,y)+c



answer = max(x,y,z)

print(answer)
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10**7)
N = int(eval(input()))
x, y, z = 0, 0, 0  # 最後に特定アクションを行った場合の最大幸福度
for _ in range(N):
    a, b, c = list(map(int, input().split()))
    x, y, z = max(y, z) + a, max(x, z) + b, max(x, y) + c
answer = max(x, y, z)
print(answer)

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
m = list(map(int, read().split()))
ABC = list(zip(m, m, m))
x, y, z = 0, 0, 0  # 最後の活動 -> 幸福度のmax
for a, b, c in ABC:
    x, y, z = max(y, z) + a, max(x, z) + b, max(x, y) + c
answer = max(x, y, z)
print(answer)

-input = sys.stdin.readline -sys.setrecursionlimit(10**7) -N = int(eval(input())) -x, y, z = 0, 0, 0  # 最後に特定アクションを行った場合の最大幸福度 -for _ in range(N): -    a, b, c = list(map(int, input().split())) +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines +N = int(readline()) +m = list(map(int, read().split())) +ABC = list(zip(m, m, m)) +x, y, z = 0, 0, 0  # 最後の活動 -> 幸福度のmax +for a, b, c in ABC: