N = int(eval(input()))

A = [0]*N

for i in range(N):

    A[i] = list(map(int, input().split()))

def solve(N,A):

    dp = [[0]*3 for i in range(N)]

    dp[0][0] = A[0][0]

    dp[0][1] = A[0][1]

    dp[0][2] = A[0][2]

    for i in range(1,N):

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

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

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

    ans = max(dp[-1])

    return ans

print((solve(N,A)))
def solve():

  N = int(eval(input()))

  dp = [[float('inf')]*3 for _ in range(N)]

  dp[0] = list(map(int, input().split()))

  for i in range(1,N):

    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][0],dp[i-1][2])+b

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

  ans = max(dp[-1])

  return ans

print((solve()))
N = int(eval(input()))
A = [0] * N
for i in range(N):
    A[i] = list(map(int, input().split()))


def solve(N, A):
    dp = [[0] * 3 for i in range(N)]
    dp[0][0] = A[0][0]
    dp[0][1] = A[0][1]
    dp[0][2] = A[0][2]
    for i in range(1, N):
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + A[i][0]
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + A[i][1]
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + A[i][2]
    ans = max(dp[-1])
    return ans


print((solve(N, A)))

def solve():
    N = int(eval(input()))
    dp = [[float("inf")] * 3 for _ in range(N)]
    dp[0] = list(map(int, input().split()))
    for i in range(1, N):
        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][0], dp[i - 1][2]) + b
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c
    ans = max(dp[-1])
    return ans


print((solve()))

-N = int(eval(input())) -A = [0] * N -for i in range(N): -    A[i] = list(map(int, input().split())) - - -def solve(N, A): -    dp = [[0] * 3 for i in range(N)] -    dp[0][0] = A[0][0] -    dp[0][1] = A[0][1] -    dp[0][2] = A[0][2] +def solve(): +    N = int(eval(input())) +    dp = [[float("inf")] * 3 for _ in range(N)] +    dp[0] = list(map(int, input().split())) -        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + A[i][0] -        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + A[i][1] -        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + A[i][2] +        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][0], dp[i - 1][2]) + b +        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c -print((solve(N, A))) +print((solve()))