import sys





def solve():

    readline = sys.stdin.buffer.readline

    mod = 10 ** 9 + 7

    n = int(readline())

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

    for i in range(n):

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

        if i == 0:

            dp[i][0] = a

            dp[i][1] = b

            dp[i][2] = c

        else:

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

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

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

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





if __name__ == '__main__':

    solve()

import sys





def solve():

    readline = sys.stdin.buffer.readline

    mod = 10 ** 9 + 7

    n = int(readline())

    a = [0] * n

    b = [0] * n

    c = [0] * n

    for i in range(n):

        av, bv, cv = list(map(int, readline().split()))

        if i == 0:

            a[i] = av

            b[i] = bv

            c[i] = cv

        else:

            a[i] = max(b[i-1] + av, c[i-1] + av)

            b[i] = max(a[i-1] + bv, c[i-1] + bv)

            c[i] = max(a[i-1] + cv, b[i-1] + cv)

    print((max(a[-1], b[-1], c[-1])))





if __name__ == '__main__':

    solve()

import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10**9 + 7
    n = int(readline())
    dp = [[0] * 3 for _ in range(n)]
    for i in range(n):
        a, b, c = list(map(int, readline().split()))
        if i == 0:
            dp[i][0] = a
            dp[i][1] = b
            dp[i][2] = c
        else:
            dp[i][0] = max(dp[i - 1][1] + a, dp[i - 1][2] + a)
            dp[i][1] = max(dp[i - 1][0] + b, dp[i - 1][2] + b)
            dp[i][2] = max(dp[i - 1][0] + c, dp[i - 1][1] + c)
    print((max(dp[-1])))


if __name__ == "__main__":
    solve()

import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10**9 + 7
    n = int(readline())
    a = [0] * n
    b = [0] * n
    c = [0] * n
    for i in range(n):
        av, bv, cv = list(map(int, readline().split()))
        if i == 0:
            a[i] = av
            b[i] = bv
            c[i] = cv
        else:
            a[i] = max(b[i - 1] + av, c[i - 1] + av)
            b[i] = max(a[i - 1] + bv, c[i - 1] + bv)
            c[i] = max(a[i - 1] + cv, b[i - 1] + cv)
    print((max(a[-1], b[-1], c[-1])))


if __name__ == "__main__":
    solve()

-    dp = [[0] * 3 for _ in range(n)] +    a = [0] * n +    b = [0] * n +    c = [0] * n -        a, b, c = list(map(int, readline().split())) +        av, bv, cv = list(map(int, readline().split())) -            dp[i][0] = a -            dp[i][1] = b -            dp[i][2] = c +            a[i] = av +            b[i] = bv +            c[i] = cv -            dp[i][0] = max(dp[i - 1][1] + a, dp[i - 1][2] + a) -            dp[i][1] = max(dp[i - 1][0] + b, dp[i - 1][2] + b) -            dp[i][2] = max(dp[i - 1][0] + c, dp[i - 1][1] + c) -    print((max(dp[-1]))) +            a[i] = max(b[i - 1] + av, c[i - 1] + av) +            b[i] = max(a[i - 1] + bv, c[i - 1] + bv) +            c[i] = max(a[i - 1] + cv, b[i - 1] + cv) +    print((max(a[-1], b[-1], c[-1])))