N = int(eval(input()))

abc = []

abc.append((0, 0, 0))

for _ in range(N):

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

    abc.append((a, b, c))



dp = [[float("inf") for _ in range(3)] for _ in range(N + 1)]

dp[0] = [0, 0, 0]



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

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

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

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



print((max(dp[-1][0], dp[-1][1], dp[-1][2])))

import sys



sys.setrecursionlimit(10 ** 6)

INF = float("inf")

MOD = 10 ** 9 + 7





def input():

    return sys.stdin.readline().strip()





def main():

    N = int(eval(input()))

    ABC = [(0, 0, 0)]

    for _ in range(N):

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

        ABC.append((a, b, c))



    dp_a = [0] * (N + 1)

    dp_b = [0] * (N + 1)

    dp_c = [0] * (N + 1)

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

        a, b, c = ABC[i]

        dp_a[i] = max(dp_b[i - 1] + a, dp_c[i - 1] + a)

        dp_b[i] = max(dp_c[i - 1] + b, dp_a[i - 1] + b)

        dp_c[i] = max(dp_a[i - 1] + c, dp_b[i - 1] + c)



    print((max(dp_a[-1], dp_b[-1], dp_c[-1])))





if __name__ == "__main__":

    main()

N = int(eval(input()))
abc = []
abc.append((0, 0, 0))
for _ in range(N):
    a, b, c = list(map(int, input().split()))
    abc.append((a, b, c))
dp = [[float("inf") for _ in range(3)] for _ in range(N + 1)]
dp[0] = [0, 0, 0]
for i in range(1, N + 1):
    dp[i][0] = max(dp[i - 1][1] + abc[i][0], dp[i - 1][2] + abc[i][0])
    dp[i][1] = max(dp[i - 1][2] + abc[i][1], dp[i - 1][0] + abc[i][1])
    dp[i][2] = max(dp[i - 1][0] + abc[i][2], dp[i - 1][1] + abc[i][2])
print((max(dp[-1][0], dp[-1][1], dp[-1][2])))

import sys

sys.setrecursionlimit(10**6)
INF = float("inf")
MOD = 10**9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N = int(eval(input()))
    ABC = [(0, 0, 0)]
    for _ in range(N):
        a, b, c = list(map(int, input().split()))
        ABC.append((a, b, c))
    dp_a = [0] * (N + 1)
    dp_b = [0] * (N + 1)
    dp_c = [0] * (N + 1)
    for i in range(1, N + 1):
        a, b, c = ABC[i]
        dp_a[i] = max(dp_b[i - 1] + a, dp_c[i - 1] + a)
        dp_b[i] = max(dp_c[i - 1] + b, dp_a[i - 1] + b)
        dp_c[i] = max(dp_a[i - 1] + c, dp_b[i - 1] + c)
    print((max(dp_a[-1], dp_b[-1], dp_c[-1])))


if __name__ == "__main__":
    main()

-N = int(eval(input())) -abc = [] -abc.append((0, 0, 0)) -for _ in range(N): -    a, b, c = list(map(int, input().split())) -    abc.append((a, b, c)) -dp = [[float("inf") for _ in range(3)] for _ in range(N + 1)] -dp[0] = [0, 0, 0] -for i in range(1, N + 1): -    dp[i][0] = max(dp[i - 1][1] + abc[i][0], dp[i - 1][2] + abc[i][0]) -    dp[i][1] = max(dp[i - 1][2] + abc[i][1], dp[i - 1][0] + abc[i][1]) -    dp[i][2] = max(dp[i - 1][0] + abc[i][2], dp[i - 1][1] + abc[i][2]) -print((max(dp[-1][0], dp[-1][1], dp[-1][2]))) +import sys + +sys.setrecursionlimit(10**6) +INF = float("inf") +MOD = 10**9 + 7 + + +def input(): +    return sys.stdin.readline().strip() + + +def main(): +    N = int(eval(input())) +    ABC = [(0, 0, 0)] +    for _ in range(N): +        a, b, c = list(map(int, input().split())) +        ABC.append((a, b, c)) +    dp_a = [0] * (N + 1) +    dp_b = [0] * (N + 1) +    dp_c = [0] * (N + 1) +    for i in range(1, N + 1): +        a, b, c = ABC[i] +        dp_a[i] = max(dp_b[i - 1] + a, dp_c[i - 1] + a) +        dp_b[i] = max(dp_c[i - 1] + b, dp_a[i - 1] + b) +        dp_c[i] = max(dp_a[i - 1] + c, dp_b[i - 1] + c) +    print((max(dp_a[-1], dp_b[-1], dp_c[-1]))) + + +if __name__ == "__main__": +    main()