n = int(eval(input()))

vv = []

for i in range(n):

    v = [int(x) for x in input().split()]

    vv.append(v)



dp = [[0 for i in range(3)] for j in range(n+1)]



for i in range(n):

    for h in range(3):

        dp[i+1][h] = max(dp[i][(h+1)%3],dp[i][(h+2)%3]) + vv[i][h]



print((max(dp[n])))
import sys

import math

from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN

from collections import deque

from bisect import bisect_left

from itertools import product

def I(): return int(sys.stdin.readline())

def MI(): return list(map(int, sys.stdin.readline().split()))

def LI(): return list(map(int, sys.stdin.readline().split()))

def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]

#文字列を一文字ずつ数字に変換、'5678'を[5,6,7,8]とできる

def LSI(): return list(map(int, list(sys.stdin.readline().rstrip())))

def LSI2(N): return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)]

#文字列として取得

def ST(): return sys.stdin.readline().rstrip()

def LST(): return sys.stdin.readline().rstrip().split()

def LST2(N): return [sys.stdin.readline().rstrip().split() for i in range(N)]

def FILL(i,h): return [i for j in range(h)]

def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]

def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]

def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]

def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)

#'0.01'や'1E1'などで指定、整数に戻すならintをかます

MOD = 1000000007

INF = float("inf")

sys.setrecursionlimit(10**6+10)



N = I()

dp = FILL2(0,N+1,3)

H = LI2(N)

for i in range(N):

    for j in range(3):

        for k in range(3):

            if j!=k:

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



print((max(dp[N])))

n = int(eval(input()))
vv = []
for i in range(n):
    v = [int(x) for x in input().split()]
    vv.append(v)
dp = [[0 for i in range(3)] for j in range(n + 1)]
for i in range(n):
    for h in range(3):
        dp[i + 1][h] = max(dp[i][(h + 1) % 3], dp[i][(h + 2) % 3]) + vv[i][h]
print((max(dp[n])))

import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
from bisect import bisect_left
from itertools import product


def I():
    return int(sys.stdin.readline())


def MI():
    return list(map(int, sys.stdin.readline().split()))


def LI():
    return list(map(int, sys.stdin.readline().split()))


def LI2(N):
    return [list(map(int, sys.stdin.readline().split())) for i in range(N)]


# 文字列を一文字ずつ数字に変換、'5678'を[5,6,7,8]とできる
def LSI():
    return list(map(int, list(sys.stdin.readline().rstrip())))


def LSI2(N):
    return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)]


# 文字列として取得
def ST():
    return sys.stdin.readline().rstrip()


def LST():
    return sys.stdin.readline().rstrip().split()


def LST2(N):
    return [sys.stdin.readline().rstrip().split() for i in range(N)]


def FILL(i, h):
    return [i for j in range(h)]


def FILL2(i, h, w):
    return [FILL(i, w) for j in range(h)]


def FILL3(i, h, w, d):
    return [FILL2(i, w, d) for j in range(h)]


def FILL4(i, h, w, d, d2):
    return [FILL3(i, w, d, d2) for j in range(h)]


def sisha(num, digit):
    return Decimal(str(num)).quantize(Decimal(digit), rounding=ROUND_HALF_UP)


#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**6 + 10)
N = I()
dp = FILL2(0, N + 1, 3)
H = LI2(N)
for i in range(N):
    for j in range(3):
        for k in range(3):
            if j != k:
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + H[i][j])
print((max(dp[N])))

-n = int(eval(input())) -vv = [] -for i in range(n): -    v = [int(x) for x in input().split()] -    vv.append(v) -dp = [[0 for i in range(3)] for j in range(n + 1)] -for i in range(n): -    for h in range(3): -        dp[i + 1][h] = max(dp[i][(h + 1) % 3], dp[i][(h + 2) % 3]) + vv[i][h] -print((max(dp[n]))) +import sys +import math +from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN +from collections import deque +from bisect import bisect_left +from itertools import product + + +def I(): +    return int(sys.stdin.readline()) + + +def MI(): +    return list(map(int, sys.stdin.readline().split())) + + +def LI(): +    return list(map(int, sys.stdin.readline().split())) + + +def LI2(N): +    return [list(map(int, sys.stdin.readline().split())) for i in range(N)] + + +# 文字列を一文字ずつ数字に変換、'5678'を[5,6,7,8]とできる +def LSI(): +    return list(map(int, list(sys.stdin.readline().rstrip()))) + + +def LSI2(N): +    return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)] + + +# 文字列として取得 +def ST(): +    return sys.stdin.readline().rstrip() + + +def LST(): +    return sys.stdin.readline().rstrip().split() + + +def LST2(N): +    return [sys.stdin.readline().rstrip().split() for i in range(N)] + + +def FILL(i, h): +    return [i for j in range(h)] + + +def FILL2(i, h, w): +    return [FILL(i, w) for j in range(h)] + + +def FILL3(i, h, w, d): +    return [FILL2(i, w, d) for j in range(h)] + + +def FILL4(i, h, w, d, d2): +    return [FILL3(i, w, d, d2) for j in range(h)] + + +def sisha(num, digit): +    return Decimal(str(num)).quantize(Decimal(digit), rounding=ROUND_HALF_UP) + + +#'0.01'や'1E1'などで指定、整数に戻すならintをかます +MOD = 1000000007 +INF = float("inf") +sys.setrecursionlimit(10**6 + 10) +N = I() +dp = FILL2(0, N + 1, 3) +H = LI2(N) +for i in range(N): +    for j in range(3): +        for k in range(3): +            if j != k: +                dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + H[i][j]) +print((max(dp[N])))