#!/usr/bin/env python3

import sys

import collections

import itertools



def solve(N: int, a: "List[int]", b: "List[int]", c: "List[int]"):

    dp = collections.defaultdict(int)



    for i,x in enumerate([a,b,c]):

        dp[0,i] = x[0]



    for i,abc in itertools.islice(enumerate(zip(a,b,c)),1,None):

        for p,q in ((p,q) for p in range(3) for q in range(3) if p != q):

            dp[i,p] = max(dp[i,p], dp[i-1,q] + abc[p])



    print((max([dp[N-1,c] for c in range(3)])))





# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)

def main():

    def iterate_tokens():

        for line in sys.stdin:

            for word in line.split():

                yield word

    tokens = iterate_tokens()

    N = int(next(tokens))  # type: int

    a = [int()] * (N)  # type: "List[int]" 

    b = [int()] * (N)  # type: "List[int]" 

    c = [int()] * (N)  # type: "List[int]" 

    for i in range(N):

        a[i] = int(next(tokens))

        b[i] = int(next(tokens))

        c[i] = int(next(tokens))

    solve(N, a, b, c)



if __name__ == '__main__':

    main()

#!/usr/bin/env python3

import sys





def solve(N: int, a: "List[int]", b: "List[int]", c: "List[int]"):

    dp = [[0 for _ in range(3)] for _ in range(N)]



    H = list(zip(a,b,c))



    for j in range(3):

        dp[0][j] = H[0][j]



    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] + H[i][j])



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





    return





# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)

def main():

    def iterate_tokens():

        for line in sys.stdin:

            for word in line.split():

                yield word

    tokens = iterate_tokens()

    N = int(next(tokens))  # type: int

    a = [int()] * (N)  # type: "List[int]"

    b = [int()] * (N)  # type: "List[int]"

    c = [int()] * (N)  # type: "List[int]"

    for i in range(N):

        a[i] = int(next(tokens))

        b[i] = int(next(tokens))

        c[i] = int(next(tokens))

    solve(N, a, b, c)



if __name__ == '__main__':

    main()

#!/usr/bin/env python3
import sys
import collections
import itertools


def solve(N: int, a: "List[int]", b: "List[int]", c: "List[int]"):
    dp = collections.defaultdict(int)
    for i, x in enumerate([a, b, c]):
        dp[0, i] = x[0]
    for i, abc in itertools.islice(enumerate(zip(a, b, c)), 1, None):
        for p, q in ((p, q) for p in range(3) for q in range(3) if p != q):
            dp[i, p] = max(dp[i, p], dp[i - 1, q] + abc[p])
    print((max([dp[N - 1, c] for c in range(3)])))


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int()] * (N)  # type: "List[int]"
    b = [int()] * (N)  # type: "List[int]"
    c = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(N, a, b, c)


if __name__ == "__main__":
    main()

#!/usr/bin/env python3
import sys


def solve(N: int, a: "List[int]", b: "List[int]", c: "List[int]"):
    dp = [[0 for _ in range(3)] for _ in range(N)]
    H = list(zip(a, b, c))
    for j in range(3):
        dp[0][j] = H[0][j]
    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] + H[i][j])
    print((max(dp[-1])))
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int()] * (N)  # type: "List[int]"
    b = [int()] * (N)  # type: "List[int]"
    c = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(N, a, b, c)


if __name__ == "__main__":
    main()

-import collections -import itertools -    dp = collections.defaultdict(int) -    for i, x in enumerate([a, b, c]): -        dp[0, i] = x[0] -    for i, abc in itertools.islice(enumerate(zip(a, b, c)), 1, None): -        for p, q in ((p, q) for p in range(3) for q in range(3) if p != q): -            dp[i, p] = max(dp[i, p], dp[i - 1, q] + abc[p]) -    print((max([dp[N - 1, c] for c in range(3)]))) +    dp = [[0 for _ in range(3)] for _ in range(N)] +    H = list(zip(a, b, c)) +    for j in range(3): +        dp[0][j] = H[0][j] +    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] + H[i][j]) +    print((max(dp[-1]))) +    return -# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template) +# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)