# coding: utf-8

# import sys

# input = sys.stdin.readline



def dp_happiness(N):

    yesterday_a, yesterday_b, yesterday_c = 0, 0, 0

    for _ in range(N):

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



        today_a = a + max(yesterday_b, yesterday_c)

        today_b = b + max(yesterday_c, yesterday_a)

        today_c = c + max(yesterday_a, yesterday_b)



        yesterday_a = today_a

        yesterday_b = today_b

        yesterday_c = today_c

    return max(today_a, today_b, today_c)



N = int(eval(input()))

print((dp_happiness(N)))
# coding: utf-8

import sys

input = sys.stdin.readline



def dp_happiness(N):

    yesterday_a, yesterday_b, yesterday_c = 0, 0, 0

    for _ in range(N):

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



        today_a = a + max(yesterday_b, yesterday_c)

        today_b = b + max(yesterday_c, yesterday_a)

        today_c = c + max(yesterday_a, yesterday_b)



        yesterday_a = today_a

        yesterday_b = today_b

        yesterday_c = today_c

    return max(today_a, today_b, today_c)



N = int(eval(input()))

print((dp_happiness(N)))
# coding: utf-8
# import sys
# input = sys.stdin.readline
def dp_happiness(N):
    yesterday_a, yesterday_b, yesterday_c = 0, 0, 0
    for _ in range(N):
        a, b, c = list(map(int, input().split()))
        today_a = a + max(yesterday_b, yesterday_c)
        today_b = b + max(yesterday_c, yesterday_a)
        today_c = c + max(yesterday_a, yesterday_b)
        yesterday_a = today_a
        yesterday_b = today_b
        yesterday_c = today_c
    return max(today_a, today_b, today_c)


N = int(eval(input()))
print((dp_happiness(N)))

# coding: utf-8
import sys

input = sys.stdin.readline


def dp_happiness(N):
    yesterday_a, yesterday_b, yesterday_c = 0, 0, 0
    for _ in range(N):
        a, b, c = list(map(int, input().split()))
        today_a = a + max(yesterday_b, yesterday_c)
        today_b = b + max(yesterday_c, yesterday_a)
        today_c = c + max(yesterday_a, yesterday_b)
        yesterday_a = today_a
        yesterday_b = today_b
        yesterday_c = today_c
    return max(today_a, today_b, today_c)


N = int(eval(input()))
print((dp_happiness(N)))

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