import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines



N = int(readline())

m = list(map(int,read().split()))

ABC = list(zip(m,m,m))



x,y,z = 0,0,0 # 最後の活動 -> 幸福度のmax

for a,b,c in ABC:

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



answer = max(x,y,z)

print(answer)
import sys



read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines



N = int(readline())

m = list(map(int, read().split()))

dp = [0, 0, 0]

for a, b, c in zip(m, m, m):

    dp = [max(dp[1], dp[2]) + a, max(dp[0], dp[2]) + b, max(dp[0], dp[1]) + c]



print((max(dp)))
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
m = list(map(int, read().split()))
ABC = list(zip(m, m, m))
x, y, z = 0, 0, 0  # 最後の活動 -> 幸福度のmax
for a, b, c in ABC:
    x, y, z = max(y, z) + a, max(x, z) + b, max(x, y) + c
answer = max(x, y, z)
print(answer)

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
m = list(map(int, read().split()))
dp = [0, 0, 0]
for a, b, c in zip(m, m, m):
    dp = [max(dp[1], dp[2]) + a, max(dp[0], dp[2]) + b, max(dp[0], dp[1]) + c]
print((max(dp)))

-ABC = list(zip(m, m, m)) -x, y, z = 0, 0, 0  # 最後の活動 -> 幸福度のmax -for a, b, c in ABC: -    x, y, z = max(y, z) + a, max(x, z) + b, max(x, y) + c -answer = max(x, y, z) -print(answer) +dp = [0, 0, 0] +for a, b, c in zip(m, m, m): +    dp = [max(dp[1], dp[2]) + a, max(dp[0], dp[2]) + b, max(dp[0], dp[1]) + c] +print((max(dp)))