n = int(eval(input()))

v = tuple(tuple(map(int, input().split())) for _ in range(n))

e = tuple(zip(*v))

# e[j][i(0-indexed)]:=i日目に活動jして得る幸福度

# print(e)



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

# dp[i(1-indexed)][j]:=i日目に活動jした最大幸福度



# もらう

for i in range(n):

    for j in range(3):

        dp[i + 1][j] = max(dp[i][(j + 1) % 3], dp[i][(j + 2) % 3]) + e[j][i]

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

def main():

    import sys

    readline = sys.stdin.readline



    n = int(readline())



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



    for i in range(1, n + 1):  # i日目の最大幸福度,1-indexed

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

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

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

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



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





if __name__ == '__main__':

    main()

n = int(eval(input()))
v = tuple(tuple(map(int, input().split())) for _ in range(n))
e = tuple(zip(*v))
# e[j][i(0-indexed)]:=i日目に活動jして得る幸福度
# print(e)
dp = tuple([0] * 3 for _ in range(n + 1))
# dp[i(1-indexed)][j]:=i日目に活動jした最大幸福度
# もらう
for i in range(n):
    for j in range(3):
        dp[i + 1][j] = max(dp[i][(j + 1) % 3], dp[i][(j + 2) % 3]) + e[j][i]
print((max(dp[n])))

def main():
    import sys

    readline = sys.stdin.readline
    n = int(readline())
    dp = [[0] * 3 for _ in range(n + 1)]
    for i in range(1, n + 1):  # i日目の最大幸福度,1-indexed
        a, b, c = list(map(int, input().split()))
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a
        dp[i][1] = max(dp[i - 1][2], dp[i - 1][0]) + b
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c
    print((max(dp[n])))


if __name__ == "__main__":
    main()

-n = int(eval(input())) -v = tuple(tuple(map(int, input().split())) for _ in range(n)) -e = tuple(zip(*v)) -# e[j][i(0-indexed)]:=i日目に活動jして得る幸福度 -# print(e) -dp = tuple([0] * 3 for _ in range(n + 1)) -# dp[i(1-indexed)][j]:=i日目に活動jした最大幸福度 -# もらう -for i in range(n): -    for j in range(3): -        dp[i + 1][j] = max(dp[i][(j + 1) % 3], dp[i][(j + 2) % 3]) + e[j][i] -print((max(dp[n]))) +def main(): +    import sys + +    readline = sys.stdin.readline +    n = int(readline()) +    dp = [[0] * 3 for _ in range(n + 1)] +    for i in range(1, n + 1):  # i日目の最大幸福度,1-indexed +        a, b, c = list(map(int, input().split())) +        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a +        dp[i][1] = max(dp[i - 1][2], dp[i - 1][0]) + b +        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c +    print((max(dp[n]))) + + +if __name__ == "__main__": +    main()