import sys

#import unittest

#import collections



def plan_vacation(activity, n):

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

	for i in range(3):

		dp[0][i] = activity[0][i]

	

	for i in range(1, n):

		for j in range(3):

			for k in range(3):

				if j != k:

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

	return max(dp[n-1])

	

	

def read_input():

	#Read the input N

	n = int(sys.stdin.readline())

	activity = [[0]* 3 for i in range(n)]

	for i in range(n):

		a = sys.stdin.readline().split()

		for j in range(3):

			activity[i][j] = int(a[j])

	

	result = plan_vacation(activity, n)

	print(result)

		

if __name__ == '__main__':

	 read_input()

import sys

#import unittest

#import collections



def plan_vacation(activity, n):

	dp = [0] * 3 

	for i in range(3):

		dp[i] = activity[0][i]

	

	for i in range(1, n):

		new_dp = [0] * 3

		for j in range(3):

			for k in range(3):

				if j != k:

					new_dp[j] = max(new_dp[j], dp[k] + activity[i][j])

		dp = new_dp

	return max(dp)

	

	

def read_input():

	#Read the input N

	n = int(sys.stdin.readline())

	activity = [[0]* 3 for i in range(n)]

	for i in range(n):

		a = sys.stdin.readline().split()

		for j in range(3):

			activity[i][j] = int(a[j])

	

	result = plan_vacation(activity, n)

	print(result)

		

if __name__ == '__main__':

	 read_input()

import sys

# import unittest
# import collections
def plan_vacation(activity, n):
    dp = [[0] * 3 for i in range(n)]
    for i in range(3):
        dp[0][i] = activity[0][i]
    for i in range(1, n):
        for j in range(3):
            for k in range(3):
                if j != k:
                    dp[i][j] = max(dp[i][j], dp[i - 1][k] + activity[i][j])
    return max(dp[n - 1])


def read_input():
    # Read the input N
    n = int(sys.stdin.readline())
    activity = [[0] * 3 for i in range(n)]
    for i in range(n):
        a = sys.stdin.readline().split()
        for j in range(3):
            activity[i][j] = int(a[j])
    result = plan_vacation(activity, n)
    print(result)


if __name__ == "__main__":
    read_input()

import sys

# import unittest
# import collections
def plan_vacation(activity, n):
    dp = [0] * 3
    for i in range(3):
        dp[i] = activity[0][i]
    for i in range(1, n):
        new_dp = [0] * 3
        for j in range(3):
            for k in range(3):
                if j != k:
                    new_dp[j] = max(new_dp[j], dp[k] + activity[i][j])
        dp = new_dp
    return max(dp)


def read_input():
    # Read the input N
    n = int(sys.stdin.readline())
    activity = [[0] * 3 for i in range(n)]
    for i in range(n):
        a = sys.stdin.readline().split()
        for j in range(3):
            activity[i][j] = int(a[j])
    result = plan_vacation(activity, n)
    print(result)


if __name__ == "__main__":
    read_input()

-    dp = [[0] * 3 for i in range(n)] +    dp = [0] * 3 -        dp[0][i] = activity[0][i] +        dp[i] = activity[0][i] +        new_dp = [0] * 3 -                    dp[i][j] = max(dp[i][j], dp[i - 1][k] + activity[i][j]) -    return max(dp[n - 1]) +                    new_dp[j] = max(new_dp[j], dp[k] + activity[i][j]) +        dp = new_dp +    return max(dp)