n=int(eval(input()))

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

for i in range(n-1):

    a1, b1, c1 = list(map(int, input().split()))

    a,b,c=a1+max(b,c),b1+max(a,c),c1+max(a,b)

print((max(a,b,c)))
import sys

input=sys.stdin.readline



n=int(eval(input()))

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

for i in range(n-1):

    a1, b1, c1 = list(map(int, input().split()))

    a,b,c=a1+max(b,c),b1+max(a,c),c1+max(a,b)

print((max(a,b,c)))
n = int(eval(input()))
a, b, c = list(map(int, input().split()))
for i in range(n - 1):
    a1, b1, c1 = list(map(int, input().split()))
    a, b, c = a1 + max(b, c), b1 + max(a, c), c1 + max(a, b)
print((max(a, b, c)))

import sys

input = sys.stdin.readline
n = int(eval(input()))
a, b, c = list(map(int, input().split()))
for i in range(n - 1):
    a1, b1, c1 = list(map(int, input().split()))
    a, b, c = a1 + max(b, c), b1 + max(a, c), c1 + max(a, b)
print((max(a, b, c)))

+import sys + +input = sys.stdin.readline