# dpC - Vacation

# 3 variables

def main():

    n = int(eval(input()))

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

    a, b, c = A[0]

    for x, y, z in A[1:]:

        a, b, c = x + max(b, c), y + max(a, c), z + max(a, b)

    print((max(a, b, c)))





if __name__ == "__main__":

    main()
# dpC - Vacation

# 3 variables

import sys

input = sys.stdin.readline



def main():

    n = int(eval(input()))

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

    a, b, c = A[0]

    for x, y, z in A[1:]:

        a, b, c = x + max(b, c), y + max(a, c), z + max(a, b)

    print((max(a, b, c)))





if __name__ == "__main__":

    main()
# dpC - Vacation
# 3 variables
def main():
    n = int(eval(input()))
    A = tuple(tuple(map(int, input().rstrip().split())) for _ in range(n))
    a, b, c = A[0]
    for x, y, z in A[1:]:
        a, b, c = x + max(b, c), y + max(a, c), z + max(a, b)
    print((max(a, b, c)))


if __name__ == "__main__":
    main()

# dpC - Vacation
# 3 variables
import sys

input = sys.stdin.readline


def main():
    n = int(eval(input()))
    A = tuple(tuple(map(int, input().rstrip().split())) for _ in range(n))
    a, b, c = A[0]
    for x, y, z in A[1:]:
        a, b, c = x + max(b, c), y + max(a, c), z + max(a, b)
    print((max(a, b, c)))


if __name__ == "__main__":
    main()

+import sys + +input = sys.stdin.readline + +