def main():

    n=int(eval(input()))

    a=[]

    for _ in range(n):

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

    dp=[]

    dp.append([a[0][0],a[0][1],a[0][2]])

    for i in range(1,n):

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

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

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

        dp.append([tmpa,tmpb,tmpc])

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

if __name__=='__main__':

    main()

def main():

    n = int(eval(input()))

    hpy = []

    for _ in range(n):

        tmp = list(map(int,input().split()))

        hpy.append(tmp)

    # a:0, b:1, c:2

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

    dp[0][0] = hpy[0][0]

    dp[0][1] = hpy[0][1]

    dp[0][2] = hpy[0][2]

    for i, abc in enumerate(dp):

        if i ==n-1:

            break

        a = max(abc[1], abc[2]) + hpy[i+1][0]

        b = max(abc[2], abc[0]) + hpy[i+1][1]

        c = max(abc[0], abc[1]) + hpy[i+1][2]

        dp[i+1][0] = a

        dp[i+1][1] = b

        dp[i+1][2] = c

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





if __name__=='__main__':

    main()

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


if __name__ == "__main__":
    main()

def main():
    n = int(eval(input()))
    hpy = []
    for _ in range(n):
        tmp = list(map(int, input().split()))
        hpy.append(tmp)
    # a:0, b:1, c:2
    dp = [[0] * 3 for i in range(n)]
    dp[0][0] = hpy[0][0]
    dp[0][1] = hpy[0][1]
    dp[0][2] = hpy[0][2]
    for i, abc in enumerate(dp):
        if i == n - 1:
            break
        a = max(abc[1], abc[2]) + hpy[i + 1][0]
        b = max(abc[2], abc[0]) + hpy[i + 1][1]
        c = max(abc[0], abc[1]) + hpy[i + 1][2]
        dp[i + 1][0] = a
        dp[i + 1][1] = b
        dp[i + 1][2] = c
    print((max(dp[n - 1])))


if __name__ == "__main__":
    main()

-    a = [] +    hpy = [] -        a.append(list(map(int, input().split()))) -    dp = [] -    dp.append([a[0][0], a[0][1], a[0][2]]) -    for i in range(1, n): -        tmpa = max(dp[i - 1][1], dp[i - 1][2]) + a[i][0] -        tmpb = max(dp[i - 1][0], dp[i - 1][2]) + a[i][1] -        tmpc = max(dp[i - 1][0], dp[i - 1][1]) + a[i][2] -        dp.append([tmpa, tmpb, tmpc]) +        tmp = list(map(int, input().split())) +        hpy.append(tmp) +    # a:0, b:1, c:2 +    dp = [[0] * 3 for i in range(n)] +    dp[0][0] = hpy[0][0] +    dp[0][1] = hpy[0][1] +    dp[0][2] = hpy[0][2] +    for i, abc in enumerate(dp): +        if i == n - 1: +            break +        a = max(abc[1], abc[2]) + hpy[i + 1][0] +        b = max(abc[2], abc[0]) + hpy[i + 1][1] +        c = max(abc[0], abc[1]) + hpy[i + 1][2] +        dp[i + 1][0] = a +        dp[i + 1][1] = b +        dp[i + 1][2] = c