#python3



def main():

    n = int(eval(input()))

    a = []

    for _ in range(n):

        x, y, z = list(map(int, input().split()))

        a.append((x, y, z))



    dp = [[0 for _ in range(3)] for _ in range(10*n)]



    for i in range(n):

        for j in range(3):

            for k in range(3):

                if j == k:

                    continue

                dp[i+1][j] = max(dp[i+1][j], dp[i][k] + a[i][j])



    ans = max(dp[n])

    print(ans)

main()
import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines

 

def main():

    n = int(readline())

    act = []

    for _ in range(n):

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

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



    #dp[i][j]:= 太郎くんがi日目に活動jを行って得る幸福度の総和の最大値



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

    for j in range(3):

        dp[0][j] = act[0][j]



    for i in range(n-1):

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

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

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



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

if __name__ == '__main__':

    main()

# python3
def main():
    n = int(eval(input()))
    a = []
    for _ in range(n):
        x, y, z = list(map(int, input().split()))
        a.append((x, y, z))
    dp = [[0 for _ in range(3)] for _ in range(10 * n)]
    for i in range(n):
        for j in range(3):
            for k in range(3):
                if j == k:
                    continue
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + a[i][j])
    ans = max(dp[n])
    print(ans)


main()

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    n = int(readline())
    act = []
    for _ in range(n):
        a, b, c = list(map(int, readline().split()))
        act.append((a, b, c))
    # dp[i][j]:= 太郎くんがi日目に活動jを行って得る幸福度の総和の最大値
    dp = [[0, 0, 0] for _ in range(n)]
    for j in range(3):
        dp[0][j] = act[0][j]
    for i in range(n - 1):
        dp[i + 1][0] = max(dp[i][1] + act[i + 1][0], dp[i][2] + act[i + 1][0])
        dp[i + 1][1] = max(dp[i][0] + act[i + 1][1], dp[i][2] + act[i + 1][1])
        dp[i + 1][2] = max(dp[i][0] + act[i + 1][2], dp[i][1] + act[i + 1][2])
    print((max(dp[n - 1])))


if __name__ == "__main__":
    main()

-# python3 -def main(): -    n = int(eval(input())) -    a = [] -    for _ in range(n): -        x, y, z = list(map(int, input().split())) -        a.append((x, y, z)) -    dp = [[0 for _ in range(3)] for _ in range(10 * n)] -    for i in range(n): -        for j in range(3): -            for k in range(3): -                if j == k: -                    continue -                dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + a[i][j]) -    ans = max(dp[n]) -    print(ans) +import sys + +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines -main() +def main(): +    n = int(readline()) +    act = [] +    for _ in range(n): +        a, b, c = list(map(int, readline().split())) +        act.append((a, b, c)) +    # dp[i][j]:= 太郎くんがi日目に活動jを行って得る幸福度の総和の最大値 +    dp = [[0, 0, 0] for _ in range(n)] +    for j in range(3): +        dp[0][j] = act[0][j] +    for i in range(n - 1): +        dp[i + 1][0] = max(dp[i][1] + act[i + 1][0], dp[i][2] + act[i + 1][0]) +        dp[i + 1][1] = max(dp[i][0] + act[i + 1][1], dp[i][2] + act[i + 1][1]) +        dp[i + 1][2] = max(dp[i][0] + act[i + 1][2], dp[i][1] + act[i + 1][2]) +    print((max(dp[n - 1]))) + + +if __name__ == "__main__": +    main()