import sys

import math

import itertools

import collections

import numpy as np



rl = sys.stdin.readline



n = int(rl())

li = [list(map(int, rl().split())) for _ in range(n)]

dp = np.zeros((n, 3), dtype=int)

dp[0] = li[0]



for i in range(1, n):

    a = dp[i-1][1] + li[i][0]

    b = dp[i-1][2] + li[i][0]

    dp[i][0] = max(a, b)

    a = dp[i-1][0] + li[i][1]

    b = dp[i-1][2] + li[i][1]

    dp[i][1] = max(a, b)

    a = dp[i-1][0] + li[i][2]

    b = dp[i-1][1] + li[i][2]

    dp[i][2] = max(a, b)

print((max(dp[-1])))



    



import sys

import math

import itertools

import collections

import numpy as np



rl = sys.stdin.readline



n = int(rl())

li = [list(map(int, rl().split())) for _ in range(n)]

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

dp[0] = li[0]



for i in range(1, n):

    a = dp[i-1][1] + li[i][0]

    b = dp[i-1][2] + li[i][0]

    dp[i][0] = max(a, b)

    a = dp[i-1][0] + li[i][1]

    b = dp[i-1][2] + li[i][1]

    dp[i][1] = max(a, b)

    a = dp[i-1][0] + li[i][2]

    b = dp[i-1][1] + li[i][2]

    dp[i][2] = max(a, b)

print((max(dp[-1])))



    



import sys
import math
import itertools
import collections
import numpy as np

rl = sys.stdin.readline
n = int(rl())
li = [list(map(int, rl().split())) for _ in range(n)]
dp = np.zeros((n, 3), dtype=int)
dp[0] = li[0]
for i in range(1, n):
    a = dp[i - 1][1] + li[i][0]
    b = dp[i - 1][2] + li[i][0]
    dp[i][0] = max(a, b)
    a = dp[i - 1][0] + li[i][1]
    b = dp[i - 1][2] + li[i][1]
    dp[i][1] = max(a, b)
    a = dp[i - 1][0] + li[i][2]
    b = dp[i - 1][1] + li[i][2]
    dp[i][2] = max(a, b)
print((max(dp[-1])))

import sys
import math
import itertools
import collections
import numpy as np

rl = sys.stdin.readline
n = int(rl())
li = [list(map(int, rl().split())) for _ in range(n)]
dp = [[0] * 3 for _ in range(n)]
dp[0] = li[0]
for i in range(1, n):
    a = dp[i - 1][1] + li[i][0]
    b = dp[i - 1][2] + li[i][0]
    dp[i][0] = max(a, b)
    a = dp[i - 1][0] + li[i][1]
    b = dp[i - 1][2] + li[i][1]
    dp[i][1] = max(a, b)
    a = dp[i - 1][0] + li[i][2]
    b = dp[i - 1][1] + li[i][2]
    dp[i][2] = max(a, b)
print((max(dp[-1])))

-dp = np.zeros((n, 3), dtype=int) +dp = [[0] * 3 for _ in range(n)]