# dpC - Vacation

# 配るDP

import sys

input = sys.stdin.readline



def main():

    n = int(eval(input()))

    A = tuple(tuple(map(int, input().rstrip().split())) for _ in range(n))

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

    dp[0] = A[0]

    for i in range(n - 1):  # i-th day

        for j in range(3):  # yesterday

            for k in range(3):  # today

                if j != k:

                    dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + A[i + 1][k])

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





if __name__ == "__main__":

    main()
# dpC - Vacation

# 3 variables

def main():

    n = int(eval(input()))

    A = tuple(tuple(map(int, input().rstrip().split())) for _ in range(n))

    a, b, c = A[0]

    for x, y, z in A[1:]:

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

    print((max(a, b, c)))





if __name__ == "__main__":

    main()
# dpC - Vacation
# 配るDP
import sys

input = sys.stdin.readline


def main():
    n = int(eval(input()))
    A = tuple(tuple(map(int, input().rstrip().split())) for _ in range(n))
    dp = [[0] * 3 for _ in range(n)]
    dp[0] = A[0]
    for i in range(n - 1):  # i-th day
        for j in range(3):  # yesterday
            for k in range(3):  # today
                if j != k:
                    dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + A[i + 1][k])
    print((max(dp[-1])))


if __name__ == "__main__":
    main()

# dpC - Vacation
# 3 variables
def main():
    n = int(eval(input()))
    A = tuple(tuple(map(int, input().rstrip().split())) for _ in range(n))
    a, b, c = A[0]
    for x, y, z in A[1:]:
        a, b, c = x + max(b, c), y + max(a, c), z + max(a, b)
    print((max(a, b, c)))


if __name__ == "__main__":
    main()

-# 配るDP -import sys - -input = sys.stdin.readline - - +# 3 variables -    dp = [[0] * 3 for _ in range(n)] -    dp[0] = A[0] -    for i in range(n - 1):  # i-th day -        for j in range(3):  # yesterday -            for k in range(3):  # today -                if j != k: -                    dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + A[i + 1][k]) -    print((max(dp[-1]))) +    a, b, c = A[0] +    for x, y, z in A[1:]: +        a, b, c = x + max(b, c), y + max(a, c), z + max(a, b) +    print((max(a, b, c)))