N = int(eval(input()))

vacation = []

for i in range(N):

    vacation.append(list(map(int, input().split())))



activities = 3

schedules = [[None for _ in range(activities)] for _ in range(N)]

schedules[0] = vacation[0]



for i in range(1, N):

    for j in range(activities):

        schedules[i][j] = max(schedules[i - 1][(j + 1) % 3], schedules[i - 1][(j + 2) % 3]) + vacation[i][j]



print((max(schedules[N - 1])))
def main():

    n = int(eval(input()))

    matrix = []

    tb = [[0] * 4 for _ in range(n + 1)]

    for _ in range(n):

        matrix.append([int(e) for e in input().split()])

    

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

        for j in range(1, 4):

            for l in range(1, 4):

                if j == l: continue

                tb[i][j] = max(tb[i][j], tb[i - 1][l] + matrix[i - 1][j - 1])

    

    print((max(tb[n])))

    return 0



if __name__ == "__main__":

    main()
N = int(eval(input()))
vacation = []
for i in range(N):
    vacation.append(list(map(int, input().split())))
activities = 3
schedules = [[None for _ in range(activities)] for _ in range(N)]
schedules[0] = vacation[0]
for i in range(1, N):
    for j in range(activities):
        schedules[i][j] = (
            max(schedules[i - 1][(j + 1) % 3], schedules[i - 1][(j + 2) % 3])
            + vacation[i][j]
        )
print((max(schedules[N - 1])))

def main():
    n = int(eval(input()))
    matrix = []
    tb = [[0] * 4 for _ in range(n + 1)]
    for _ in range(n):
        matrix.append([int(e) for e in input().split()])
    for i in range(1, n + 1):
        for j in range(1, 4):
            for l in range(1, 4):
                if j == l:
                    continue
                tb[i][j] = max(tb[i][j], tb[i - 1][l] + matrix[i - 1][j - 1])
    print((max(tb[n])))
    return 0


if __name__ == "__main__":
    main()

-N = int(eval(input())) -vacation = [] -for i in range(N): -    vacation.append(list(map(int, input().split()))) -activities = 3 -schedules = [[None for _ in range(activities)] for _ in range(N)] -schedules[0] = vacation[0] -for i in range(1, N): -    for j in range(activities): -        schedules[i][j] = ( -            max(schedules[i - 1][(j + 1) % 3], schedules[i - 1][(j + 2) % 3]) -            + vacation[i][j] -        ) -print((max(schedules[N - 1]))) +def main(): +    n = int(eval(input())) +    matrix = [] +    tb = [[0] * 4 for _ in range(n + 1)] +    for _ in range(n): +        matrix.append([int(e) for e in input().split()]) +    for i in range(1, n + 1): +        for j in range(1, 4): +            for l in range(1, 4): +                if j == l: +                    continue +                tb[i][j] = max(tb[i][j], tb[i - 1][l] + matrix[i - 1][j - 1]) +    print((max(tb[n]))) +    return 0 + + +if __name__ == "__main__": +    main()