n = int(eval(input()))

dp =[[0]*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] = a + max(dp[i-1][1],dp[i-1][2])

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

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

print((max(dp[n-1])))
def I(): return int(eval(input()))

def LI(): return list(map(int,input().split()))

def MI(): return list(map(int,input().split()))

def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

n = I()

act = [[0,0,0]] + LLI(n)

dp = [[-10**10,-10**10,-10**10] for _ in range(n+1)]

#dp[i][0]はi日目でA選ぶときの幸福度の最大値

#dp[i][1]はi日目でB選ぶときの幸福度の最大値

#dp[i][2]はi日目でC選ぶときの幸福度の最大値

#1-indexedで考えよう

dp[1] = act[1]

for i in range(2,n+1):

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

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

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

print((max(dp[n][0],dp[n][1],dp[n][2])))

n = int(eval(input()))
dp = [[0] * 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] = a + max(dp[i - 1][1], dp[i - 1][2])
    dp[i][1] = b + max(dp[i - 1][0], dp[i - 1][2])
    dp[i][2] = c + max(dp[i - 1][0], dp[i - 1][1])
print((max(dp[n - 1])))

def I():
    return int(eval(input()))


def LI():
    return list(map(int, input().split()))


def MI():
    return list(map(int, input().split()))


def LLI(n):
    return [list(map(int, input().split())) for _ in range(n)]


n = I()
act = [[0, 0, 0]] + LLI(n)
dp = [[-(10**10), -(10**10), -(10**10)] for _ in range(n + 1)]
# dp[i][0]はi日目でA選ぶときの幸福度の最大値
# dp[i][1]はi日目でB選ぶときの幸福度の最大値
# dp[i][2]はi日目でC選ぶときの幸福度の最大値
# 1-indexedで考えよう
dp[1] = act[1]
for i in range(2, n + 1):
    dp[i][0] = max(dp[i - 1][1] + act[i][0], dp[i - 1][2] + act[i][0])
    dp[i][1] = max(dp[i - 1][0] + act[i][1], dp[i - 1][2] + act[i][1])
    dp[i][2] = max(dp[i - 1][1] + act[i][2], dp[i - 1][0] + act[i][2])
print((max(dp[n][0], dp[n][1], dp[n][2])))

-n = int(eval(input())) -dp = [[0] * 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] = a + max(dp[i - 1][1], dp[i - 1][2]) -    dp[i][1] = b + max(dp[i - 1][0], dp[i - 1][2]) -    dp[i][2] = c + max(dp[i - 1][0], dp[i - 1][1]) -print((max(dp[n - 1]))) +def I(): +    return int(eval(input())) + + +def LI(): +    return list(map(int, input().split())) + + +def MI(): +    return list(map(int, input().split())) + + +def LLI(n): +    return [list(map(int, input().split())) for _ in range(n)] + + +n = I() +act = [[0, 0, 0]] + LLI(n) +dp = [[-(10**10), -(10**10), -(10**10)] for _ in range(n + 1)] +# dp[i][0]はi日目でA選ぶときの幸福度の最大値 +# dp[i][1]はi日目でB選ぶときの幸福度の最大値 +# dp[i][2]はi日目でC選ぶときの幸福度の最大値 +# 1-indexedで考えよう +dp[1] = act[1] +for i in range(2, n + 1): +    dp[i][0] = max(dp[i - 1][1] + act[i][0], dp[i - 1][2] + act[i][0]) +    dp[i][1] = max(dp[i - 1][0] + act[i][1], dp[i - 1][2] + act[i][1]) +    dp[i][2] = max(dp[i - 1][1] + act[i][2], dp[i - 1][0] + act[i][2]) +print((max(dp[n][0], dp[n][1], dp[n][2])))