def main():

    n, *abc = list(map(int, open(0).read().split()))

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

    for i, (a, b, c) in enumerate(zip(abc[::3], abc[1::3], abc[2::3]), 1):

        x, y, z = dp[i - 1]

        dp[i] = [a + max(y, z), b + max(z, x), c + max(x, y)]



    ans = max(dp[-1])

    print(ans)





if __name__ == '__main__':

    main()

def main():

    n, *abc = list(map(int, open(0).read().split()))

    x, y, z = 0, 0, 0

    for i, (a, b, c) in enumerate(zip(*[iter(abc)] * 3), 1):

        x, y, z = a + max(y, z), b + max(z, x), c + max(x, y)

    

    ans = max([x, y, z])

    print(ans)





if __name__ == '__main__':

    main()

def main():
    n, *abc = list(map(int, open(0).read().split()))
    dp = [[0, 0, 0] for _ in range(n + 1)]
    for i, (a, b, c) in enumerate(zip(abc[::3], abc[1::3], abc[2::3]), 1):
        x, y, z = dp[i - 1]
        dp[i] = [a + max(y, z), b + max(z, x), c + max(x, y)]
    ans = max(dp[-1])
    print(ans)


if __name__ == "__main__":
    main()

def main():
    n, *abc = list(map(int, open(0).read().split()))
    x, y, z = 0, 0, 0
    for i, (a, b, c) in enumerate(zip(*[iter(abc)] * 3), 1):
        x, y, z = a + max(y, z), b + max(z, x), c + max(x, y)
    ans = max([x, y, z])
    print(ans)


if __name__ == "__main__":
    main()

-    dp = [[0, 0, 0] for _ in range(n + 1)] -    for i, (a, b, c) in enumerate(zip(abc[::3], abc[1::3], abc[2::3]), 1): -        x, y, z = dp[i - 1] -        dp[i] = [a + max(y, z), b + max(z, x), c + max(x, y)] -    ans = max(dp[-1]) +    x, y, z = 0, 0, 0 +    for i, (a, b, c) in enumerate(zip(*[iter(abc)] * 3), 1): +        x, y, z = a + max(y, z), b + max(z, x), c + max(x, y) +    ans = max([x, y, z])