# 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)

	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

import sys

readline = sys.stdin.buffer.readline

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

gete = lambda fn: fn(readline())



def main():

	n=gete(int)

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

	

	

	for i in range(n):

		a,b,c = geta(int)

		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)
    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
import sys

readline = sys.stdin.buffer.readline
geta = lambda fn: list(map(fn, readline().split()))
gete = lambda fn: fn(readline())


def main():
    n = gete(int)
    dp = [[0] * 3 for _ in range(n + 1)]
    for i in range(n):
        a, b, c = geta(int)
        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()

-geta = lambda fn: list(map(fn, input().split())) -gete = lambda fn: fn(eval(input())) +import sys + +readline = sys.stdin.buffer.readline +geta = lambda fn: list(map(fn, readline().split())) +gete = lambda fn: fn(readline()) -        a, b, c = list(map(int, input().split())) +        a, b, c = geta(int)