N = int(eval(input()))

data = [[int(i) for i in input().split()] for _ in range(N)]



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

dp[0] = data[0]



for i in range(1, N):

    for j in range(3):

        dp[i][j] = data[i][j] + max(dp[i-1][(j+1)%3], dp[i-1][(j+2)%3])

print((max(dp[N-1])))
# region header

import sys

import math

from bisect import bisect_left, bisect_right, insort_left, insort_right

from collections import defaultdict, deque, Counter

from copy import deepcopy

from fractions import gcd

from functools import lru_cache, reduce

from heapq import heappop, heappush

from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement

from math import ceil, floor, factorial, log, sqrt, sin, cos

from operator import itemgetter

from string import ascii_lowercase, ascii_uppercase, digits

sys.setrecursionlimit(10**6)

INF = float('inf')

MOD = 10 ** 9 + 7

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

def ri(): return int(rs())

def rf(): return float(rs())

def rs_(): return [_ for _ in rs().split()]

def ri_(): return [int(_) for _ in rs().split()]

def rf_(): return [float(_) for _ in rs().split()]

def divisors(n, sortresult=True):

    div = []

    for i in range(1, int(n**0.5)+1):

        if n % i == 0:

            div.append(i)

            if i != n // i:

                div.append(n//i)

    if sortresult:

        div.sort()

    return div

# endregion

N = ri()

a = [0] * N

b = [0] * N

c = [0] * N

for i in range(N):

    a[i], b[i], c[i] = ri_()

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

dp[0][0] = a[0]

dp[0][1] = b[0]

dp[0][2] = c[0]

for i in range(1, N):

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

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

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

print((max(dp[N - 1])))
N = int(eval(input()))
data = [[int(i) for i in input().split()] for _ in range(N)]
dp = [[0] * 3 for _ in range(N)]
dp[0] = data[0]
for i in range(1, N):
    for j in range(3):
        dp[i][j] = data[i][j] + max(dp[i - 1][(j + 1) % 3], dp[i - 1][(j + 2) % 3])
print((max(dp[N - 1])))

# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import (
    accumulate,
    groupby,
    product,
    permutations,
    combinations,
    combinations_with_replacement,
)
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits

sys.setrecursionlimit(10**6)
INF = float("inf")
MOD = 10**9 + 7


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


def ri():
    return int(rs())


def rf():
    return float(rs())


def rs_():
    return [_ for _ in rs().split()]


def ri_():
    return [int(_) for _ in rs().split()]


def rf_():
    return [float(_) for _ in rs().split()]


def divisors(n, sortresult=True):
    div = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            div.append(i)
            if i != n // i:
                div.append(n // i)
    if sortresult:
        div.sort()
    return div


# endregion
N = ri()
a = [0] * N
b = [0] * N
c = [0] * N
for i in range(N):
    a[i], b[i], c[i] = ri_()
dp = [[0] * 3 for _ in range(N)]
dp[0][0] = a[0]
dp[0][1] = b[0]
dp[0][2] = c[0]
for i in range(1, N):
    dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i]
    dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i]
    dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i]
print((max(dp[N - 1])))

-N = int(eval(input())) -data = [[int(i) for i in input().split()] for _ in range(N)] +# region header +import sys +import math +from bisect import bisect_left, bisect_right, insort_left, insort_right +from collections import defaultdict, deque, Counter +from copy import deepcopy +from fractions import gcd +from functools import lru_cache, reduce +from heapq import heappop, heappush +from itertools import ( +    accumulate, +    groupby, +    product, +    permutations, +    combinations, +    combinations_with_replacement, +) +from math import ceil, floor, factorial, log, sqrt, sin, cos +from operator import itemgetter +from string import ascii_lowercase, ascii_uppercase, digits + +sys.setrecursionlimit(10**6) +INF = float("inf") +MOD = 10**9 + 7 + + +def rs(): +    return sys.stdin.readline().rstrip() + + +def ri(): +    return int(rs()) + + +def rf(): +    return float(rs()) + + +def rs_(): +    return [_ for _ in rs().split()] + + +def ri_(): +    return [int(_) for _ in rs().split()] + + +def rf_(): +    return [float(_) for _ in rs().split()] + + +def divisors(n, sortresult=True): +    div = [] +    for i in range(1, int(n**0.5) + 1): +        if n % i == 0: +            div.append(i) +            if i != n // i: +                div.append(n // i) +    if sortresult: +        div.sort() +    return div + + +# endregion +N = ri() +a = [0] * N +b = [0] * N +c = [0] * N +for i in range(N): +    a[i], b[i], c[i] = ri_() -dp[0] = data[0] +dp[0][0] = a[0] +dp[0][1] = b[0] +dp[0][2] = c[0] -    for j in range(3): -        dp[i][j] = data[i][j] + max(dp[i - 1][(j + 1) % 3], dp[i - 1][(j + 2) % 3]) +    dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i] +    dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i] +    dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i]