import cmath

import numpy as np

import sys



INF=10**18

MOD=10**9+7

MAX=10**5+7



def main():

    N=int(eval(input()))

    dp=[0, 0, 0]

    for _ in range(N):

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

        ndp=[0, 0, 0]

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

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

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

        dp=ndp

    print((max(dp)))



if __name__=='__main__':

    main()

import sys



INF=10**18

MOD=10**9+7

MAX=10**5+7



def main():

    N=int(eval(input()))

    dp=[0, 0, 0]

    for line in sys.stdin.readlines():

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

        ndp=[0, 0, 0]

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

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

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

        dp=ndp

    print((max(dp)))



main()

import cmath
import numpy as np
import sys

INF = 10**18
MOD = 10**9 + 7
MAX = 10**5 + 7


def main():
    N = int(eval(input()))
    dp = [0, 0, 0]
    for _ in range(N):
        a, b, c = list(map(int, input().split()))
        ndp = [0, 0, 0]
        ndp[0] = max(dp[1], dp[2]) + a
        ndp[1] = max(dp[2], dp[0]) + b
        ndp[2] = max(dp[0], dp[1]) + c
        dp = ndp
    print((max(dp)))


if __name__ == "__main__":
    main()

import sys

INF = 10**18
MOD = 10**9 + 7
MAX = 10**5 + 7


def main():
    N = int(eval(input()))
    dp = [0, 0, 0]
    for line in sys.stdin.readlines():
        a, b, c = list(map(int, line.split()))
        ndp = [0, 0, 0]
        ndp[0] = max(dp[1], dp[2]) + a
        ndp[1] = max(dp[2], dp[0]) + b
        ndp[2] = max(dp[0], dp[1]) + c
        dp = ndp
    print((max(dp)))


main()

-import cmath -import numpy as np -    for _ in range(N): -        a, b, c = list(map(int, input().split())) +    for line in sys.stdin.readlines(): +        a, b, c = list(map(int, line.split())) -if __name__ == "__main__": -    main() +main()