n = int(eval(input()))

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

a.insert(0,[0,0,0])



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



for i, a in enumerate(a):

  dp_1 = dp[i-1]

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

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

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



print((max(dp[n])))

def main():

    n = int(eval(input()))

    abc = []

    for _ in range(n):

        abc.append(tuple(map(int, input().split())))

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

    dp[0][0] = abc[0][0]

    dp[0][1] = abc[0][1]

    dp[0][2] = abc[0][2]



    for i in range(1, n):

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

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

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

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



if __name__ == '__main__':

    main()
n = int(eval(input()))
a = [list(map(int, input().split())) for _ in range(n)]
a.insert(0, [0, 0, 0])
dp = [[0, 0, 0] for _ in range(n + 1)]
for i, a in enumerate(a):
    dp_1 = dp[i - 1]
    dp[i][0] = max(dp_1[1], dp_1[2]) + a[0]
    dp[i][1] = max(dp_1[0], dp_1[2]) + a[1]
    dp[i][2] = max(dp_1[0], dp_1[1]) + a[2]
print((max(dp[n])))

def main():
    n = int(eval(input()))
    abc = []
    for _ in range(n):
        abc.append(tuple(map(int, input().split())))
    dp = [[0, 0, 0] for _ in range(n)]
    dp[0][0] = abc[0][0]
    dp[0][1] = abc[0][1]
    dp[0][2] = abc[0][2]
    for i in range(1, n):
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + abc[i][0]
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + abc[i][1]
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + abc[i][2]
    print((max(dp[n - 1])))


if __name__ == "__main__":
    main()

-n = int(eval(input())) -a = [list(map(int, input().split())) for _ in range(n)] -a.insert(0, [0, 0, 0]) -dp = [[0, 0, 0] for _ in range(n + 1)] -for i, a in enumerate(a): -    dp_1 = dp[i - 1] -    dp[i][0] = max(dp_1[1], dp_1[2]) + a[0] -    dp[i][1] = max(dp_1[0], dp_1[2]) + a[1] -    dp[i][2] = max(dp_1[0], dp_1[1]) + a[2] -print((max(dp[n]))) +def main(): +    n = int(eval(input())) +    abc = [] +    for _ in range(n): +        abc.append(tuple(map(int, input().split()))) +    dp = [[0, 0, 0] for _ in range(n)] +    dp[0][0] = abc[0][0] +    dp[0][1] = abc[0][1] +    dp[0][2] = abc[0][2] +    for i in range(1, n): +        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + abc[i][0] +        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + abc[i][1] +        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + abc[i][2] +    print((max(dp[n - 1]))) + + +if __name__ == "__main__": +    main()