# import sys

# sys.setrecursionlimit(10**5)

# from collections import defaultdict

geta = lambda fn: list(map(fn, input().split()))

gete = lambda fn: fn(eval(input()))



def main():

    N = gete(int)

    a = [0]*(N+1)

    b, c = a[:], a[:]



    for i in range(N):

        av, bv, cv = geta(int)

        a[i+1] = max(av + b[i], av + c[i])

        b[i+1] = max(bv + c[i], bv + a[i])

        c[i+1] = max(cv + a[i], cv + b[i])



    print((max(a[-1], b[-1], c[-1])))



if __name__ == "__main__":

    main()
# copy and paste (check calc time)

import sys

 

read = sys.stdin.buffer.read

input = sys.stdin.buffer.readline

inputs = sys.stdin.buffer.readlines

 

 

# mod=10**9+7

# rstrip().decode('utf-8')

# map(int,input().split())

# import numpy as np

 

def main():

	n=int(eval(input()))

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

	

	

	for i in range(n):

		a,b,c=list(map(int,input().split()))

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

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

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

		

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

	

	

	

if __name__ == "__main__":

	main()
# import sys
# sys.setrecursionlimit(10**5)
# from collections import defaultdict
geta = lambda fn: list(map(fn, input().split()))
gete = lambda fn: fn(eval(input()))


def main():
    N = gete(int)
    a = [0] * (N + 1)
    b, c = a[:], a[:]
    for i in range(N):
        av, bv, cv = geta(int)
        a[i + 1] = max(av + b[i], av + c[i])
        b[i + 1] = max(bv + c[i], bv + a[i])
        c[i + 1] = max(cv + a[i], cv + b[i])
    print((max(a[-1], b[-1], c[-1])))


if __name__ == "__main__":
    main()

# copy and paste (check calc time)
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines
# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np
def main():
    n = int(eval(input()))
    dp = [[0] * 3 for _ in range(n + 1)]
    for i in range(n):
        a, b, c = list(map(int, input().split()))
        dp[i + 1][0] = max(dp[i][1], dp[i][2]) + a
        dp[i + 1][1] = max(dp[i][2], dp[i][0]) + b
        dp[i + 1][2] = max(dp[i][0], dp[i][1]) + c
    print((max(dp[n][0], dp[n][1], dp[n][2])))


if __name__ == "__main__":
    main()

-# import sys -# sys.setrecursionlimit(10**5) -# from collections import defaultdict -geta = lambda fn: list(map(fn, input().split())) -gete = lambda fn: fn(eval(input())) +# copy and paste (check calc time) +import sys - +read = sys.stdin.buffer.read +input = sys.stdin.buffer.readline +inputs = sys.stdin.buffer.readlines +# mod=10**9+7 +# rstrip().decode('utf-8') +# map(int,input().split()) +# import numpy as np -    N = gete(int) -    a = [0] * (N + 1) -    b, c = a[:], a[:] -    for i in range(N): -        av, bv, cv = geta(int) -        a[i + 1] = max(av + b[i], av + c[i]) -        b[i + 1] = max(bv + c[i], bv + a[i]) -        c[i + 1] = max(cv + a[i], cv + b[i]) -    print((max(a[-1], b[-1], c[-1]))) +    n = int(eval(input())) +    dp = [[0] * 3 for _ in range(n + 1)] +    for i in range(n): +        a, b, c = list(map(int, input().split())) +        dp[i + 1][0] = max(dp[i][1], dp[i][2]) + a +        dp[i + 1][1] = max(dp[i][2], dp[i][0]) + b +        dp[i + 1][2] = max(dp[i][0], dp[i][1]) + c +    print((max(dp[n][0], dp[n][1], dp[n][2])))