def main():

    import sys

    readline = sys.stdin.readline



    n = int(readline())



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



    for i in range(1, n + 1):  # i日目の最大幸福度,1-indexed

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

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

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

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



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





if __name__ == '__main__':

    main()

def main():

    import sys

    readline = sys.stdin.readline



    n = int(readline())



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



    for i in range(1, n + 1):  # i日目の最大幸福度,1-indexed

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

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

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

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



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





if __name__ == '__main__':

    main()

def main():
    import sys

    readline = sys.stdin.readline
    n = int(readline())
    dp = [[0] * 3 for _ in range(n + 1)]
    for i in range(1, n + 1):  # i日目の最大幸福度,1-indexed
        a, b, c = list(map(int, input().split()))
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a
        dp[i][1] = max(dp[i - 1][2], dp[i - 1][0]) + b
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c
    print((max(dp[n])))


if __name__ == "__main__":
    main()

def main():
    import sys

    readline = sys.stdin.readline
    n = int(readline())
    dp = [[0] * 3 for _ in range(n + 1)]
    for i in range(1, n + 1):  # i日目の最大幸福度,1-indexed
        a, b, c = list(map(int, readline().split()))
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a
        dp[i][1] = max(dp[i - 1][2], dp[i - 1][0]) + b
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c
    print((max(dp[n])))


if __name__ == "__main__":
    main()

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