def main():

    n = int(eval(input()))

    abc = []

    for _ in range(n):

        abc.append(tuple(map(int, input().split())))

    dp = [[0,0,0] for _ in range(n)]

    dp[0][0] = abc[0][0]

    dp[0][1] = abc[0][1]

    dp[0][2] = abc[0][2]



    for i in range(1, n):

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

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

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

    print((max(dp[n-1])))



if __name__ == '__main__':

    main()
import sys

input = sys.stdin.readline



def main():

    n = int(eval(input()))

    colA, colB, colC = list(map(int, input().split()))

    for i1 in range(1, n):

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

        colA, colB, colC = a + max(colB, colC), b + max(colA, colC), c + max(colA, colB)

    print((max(colA, colB, colC)))



if __name__ == '__main__':

    main()

def main():
    n = int(eval(input()))
    abc = []
    for _ in range(n):
        abc.append(tuple(map(int, input().split())))
    dp = [[0, 0, 0] for _ in range(n)]
    dp[0][0] = abc[0][0]
    dp[0][1] = abc[0][1]
    dp[0][2] = abc[0][2]
    for i in range(1, n):
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + abc[i][0]
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + abc[i][1]
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + abc[i][2]
    print((max(dp[n - 1])))


if __name__ == "__main__":
    main()

import sys

input = sys.stdin.readline


def main():
    n = int(eval(input()))
    colA, colB, colC = list(map(int, input().split()))
    for i1 in range(1, n):
        a, b, c = list(map(int, input().split()))
        colA, colB, colC = a + max(colB, colC), b + max(colA, colC), c + max(colA, colB)
    print((max(colA, colB, colC)))


if __name__ == "__main__":
    main()

+import sys + +input = sys.stdin.readline + + -    abc = [] -    for _ in range(n): -        abc.append(tuple(map(int, input().split()))) -    dp = [[0, 0, 0] for _ in range(n)] -    dp[0][0] = abc[0][0] -    dp[0][1] = abc[0][1] -    dp[0][2] = abc[0][2] -    for i in range(1, n): -        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + abc[i][0] -        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + abc[i][1] -        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + abc[i][2] -    print((max(dp[n - 1]))) +    colA, colB, colC = list(map(int, input().split())) +    for i1 in range(1, n): +        a, b, c = list(map(int, input().split())) +        colA, colB, colC = a + max(colB, colC), b + max(colA, colC), c + max(colA, colB) +    print((max(colA, colB, colC)))