n=int(eval(input()))

ma,mb,mc=0,0,0

for _ in range(n):

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

  x,y,z=ma,mb,mc

  ma=a+max([y,z])

  mb=b+max([z,x])

  mc=c+max([x,y])

print((max([ma,mb,mc])))
def main():

    n, *abc = list(map(int, open(0).read().split()))

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

    for i, (a, b, c) in enumerate(zip(abc[::3], abc[1::3], abc[2::3]), 1):

        x, y, z = dp[i - 1]

        dp[i] = [a + max(y, z), b + max(z, x), c + max(x, y)]



    ans = max(dp[-1])

    print(ans)





if __name__ == '__main__':

    main()

n = int(eval(input()))
ma, mb, mc = 0, 0, 0
for _ in range(n):
    a, b, c = list(map(int, input().split()))
    x, y, z = ma, mb, mc
    ma = a + max([y, z])
    mb = b + max([z, x])
    mc = c + max([x, y])
print((max([ma, mb, mc])))

def main():
    n, *abc = list(map(int, open(0).read().split()))
    dp = [[0, 0, 0] for _ in range(n + 1)]
    for i, (a, b, c) in enumerate(zip(abc[::3], abc[1::3], abc[2::3]), 1):
        x, y, z = dp[i - 1]
        dp[i] = [a + max(y, z), b + max(z, x), c + max(x, y)]
    ans = max(dp[-1])
    print(ans)


if __name__ == "__main__":
    main()

-n = int(eval(input())) -ma, mb, mc = 0, 0, 0 -for _ in range(n): -    a, b, c = list(map(int, input().split())) -    x, y, z = ma, mb, mc -    ma = a + max([y, z]) -    mb = b + max([z, x]) -    mc = c + max([x, y]) -print((max([ma, mb, mc]))) +def main(): +    n, *abc = list(map(int, open(0).read().split())) +    dp = [[0, 0, 0] for _ in range(n + 1)] +    for i, (a, b, c) in enumerate(zip(abc[::3], abc[1::3], abc[2::3]), 1): +        x, y, z = dp[i - 1] +        dp[i] = [a + max(y, z), b + max(z, x), c + max(x, y)] +    ans = max(dp[-1]) +    print(ans) + + +if __name__ == "__main__": +    main()