import sys

input=sys.stdin.readline



def main():

    N = int(eval(input()))

    a1,b1,c1 = 0,0,0

    for _ in range(N):

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

        a0,b0,c0 = a1,b1,c1

        a1 = max(b0, c0) + a # b or c => a

        b1 = max(a0, c0) + b # a or c => b

        c1 = max(a0, b0) + c # a or b => c



    print((max(a1,b1,c1)))



if __name__ == '__main__':

    main()

import sys

input=sys.stdin.readline



def main():

    N = int(eval(input()))

    a1,b1,c1 = 0,0,0

    for _ in range(N):

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

        a0,b0,c0 = a1,b1,c1

        a1 = a + (b0 if b0 > c0 else c0)

        b1 = b + (a0 if a0 > c0 else c0)

        c1 = c + (a0 if a0 > b0 else b0)



    print((max(a1,b1,c1)))



if __name__ == '__main__':

    main()

import sys

input = sys.stdin.readline


def main():
    N = int(eval(input()))
    a1, b1, c1 = 0, 0, 0
    for _ in range(N):
        a, b, c = list(map(int, input().split()))
        a0, b0, c0 = a1, b1, c1
        a1 = max(b0, c0) + a  # b or c => a
        b1 = max(a0, c0) + b  # a or c => b
        c1 = max(a0, b0) + c  # a or b => c
    print((max(a1, b1, c1)))


if __name__ == "__main__":
    main()

import sys

input = sys.stdin.readline


def main():
    N = int(eval(input()))
    a1, b1, c1 = 0, 0, 0
    for _ in range(N):
        a, b, c = list(map(int, input().split()))
        a0, b0, c0 = a1, b1, c1
        a1 = a + (b0 if b0 > c0 else c0)
        b1 = b + (a0 if a0 > c0 else c0)
        c1 = c + (a0 if a0 > b0 else b0)
    print((max(a1, b1, c1)))


if __name__ == "__main__":
    main()

-        a1 = max(b0, c0) + a  # b or c => a -        b1 = max(a0, c0) + b  # a or c => b -        c1 = max(a0, b0) + c  # a or b => c +        a1 = a + (b0 if b0 > c0 else c0) +        b1 = b + (a0 if a0 > c0 else c0) +        c1 = c + (a0 if a0 > b0 else b0)