# -*- coding: utf-8 -*-





def main():

    n = int(eval(input()))

    work_list = [tuple(map(int, input().split())) for i in range(n)]



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

    for i, work in enumerate(work_list):

        for i_now in range(3):

            for i_pre in range(3):

                if i_now == i_pre:

                    continue



                dp[i + 1][i_now] = max(dp[i + 1][i_now], dp[i][i_pre] + work[i_now])



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





if __name__ == '__main__':

    main()

# -*- coding: utf-8 -*-





def main():

    n = int(eval(input()))

    work_list = [tuple(map(int, input().split())) for i in range(n)]



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

    # for i, work in enumerate(work_list):

    #     for i_now in range(3):

    #         for i_pre in range(3):

    #             if i_now == i_pre:

    #                 continue

    #

    #             dp[i + 1][i_now] = max(dp[i + 1][i_now], dp[i][i_pre] + work[i_now])

    dp_pre = [0] * 3

    dp_now = [0] * 3

    for i, work in enumerate(work_list):

        for i_now in range(3):

            for i_pre in range(3):

                if i_now == i_pre:

                    continue



                dp_now[i_now] = max(dp_now[i_now], dp_pre[i_pre] + work[i_now])



        dp_pre[0] = dp_now[0]

        dp_pre[1] = dp_now[1]

        dp_pre[2] = dp_now[2]



    print((max(dp_now)))





if __name__ == '__main__':

    main()

# -*- coding: utf-8 -*-
def main():
    n = int(eval(input()))
    work_list = [tuple(map(int, input().split())) for i in range(n)]
    dp = [[0] * 3 for i in range(n + 1)]
    for i, work in enumerate(work_list):
        for i_now in range(3):
            for i_pre in range(3):
                if i_now == i_pre:
                    continue
                dp[i + 1][i_now] = max(dp[i + 1][i_now], dp[i][i_pre] + work[i_now])
    print((max(dp[-1])))


if __name__ == "__main__":
    main()

# -*- coding: utf-8 -*-
def main():
    n = int(eval(input()))
    work_list = [tuple(map(int, input().split())) for i in range(n)]
    # dp = [[0] * 3 for i in range(n + 1)]
    # for i, work in enumerate(work_list):
    #     for i_now in range(3):
    #         for i_pre in range(3):
    #             if i_now == i_pre:
    #                 continue
    #
    #             dp[i + 1][i_now] = max(dp[i + 1][i_now], dp[i][i_pre] + work[i_now])
    dp_pre = [0] * 3
    dp_now = [0] * 3
    for i, work in enumerate(work_list):
        for i_now in range(3):
            for i_pre in range(3):
                if i_now == i_pre:
                    continue
                dp_now[i_now] = max(dp_now[i_now], dp_pre[i_pre] + work[i_now])
        dp_pre[0] = dp_now[0]
        dp_pre[1] = dp_now[1]
        dp_pre[2] = dp_now[2]
    print((max(dp_now)))


if __name__ == "__main__":
    main()

-    dp = [[0] * 3 for i in range(n + 1)] +    # dp = [[0] * 3 for i in range(n + 1)] +    # for i, work in enumerate(work_list): +    #     for i_now in range(3): +    #         for i_pre in range(3): +    #             if i_now == i_pre: +    #                 continue +    # +    #             dp[i + 1][i_now] = max(dp[i + 1][i_now], dp[i][i_pre] + work[i_now]) +    dp_pre = [0] * 3 +    dp_now = [0] * 3 -                dp[i + 1][i_now] = max(dp[i + 1][i_now], dp[i][i_pre] + work[i_now]) -    print((max(dp[-1]))) +                dp_now[i_now] = max(dp_now[i_now], dp_pre[i_pre] + work[i_now]) +        dp_pre[0] = dp_now[0] +        dp_pre[1] = dp_now[1] +        dp_pre[2] = dp_now[2] +    print((max(dp_now)))