n = int(eval(input()))

a = [0]

b = [0]

c = [0]



for i in range(n):

    aa,bb,cc = list(map(int,input().split()))

    a.append(max(b[i] + aa, c[i] + aa))

    b.append(max(a[i] + bb, c[i] + bb))

    c.append(max(a[i] + cc, b[i] + cc))

    

print((max(a[-1], b[-1], c[-1])))

def main():

  n = int(eval(input()))

  a = [0]

  b = [0]

  c = [0]



  for i in range(n):

      aa,bb,cc = list(map(int,input().split()))

      a.append(max(b[i] + aa, c[i] + aa))

      b.append(max(a[i] + bb, c[i] + bb))

      c.append(max(a[i] + cc, b[i] + cc))



  print((max(a[-1], b[-1], c[-1])))



main()
n = int(eval(input()))
a = [0]
b = [0]
c = [0]
for i in range(n):
    aa, bb, cc = list(map(int, input().split()))
    a.append(max(b[i] + aa, c[i] + aa))
    b.append(max(a[i] + bb, c[i] + bb))
    c.append(max(a[i] + cc, b[i] + cc))
print((max(a[-1], b[-1], c[-1])))

def main():
    n = int(eval(input()))
    a = [0]
    b = [0]
    c = [0]
    for i in range(n):
        aa, bb, cc = list(map(int, input().split()))
        a.append(max(b[i] + aa, c[i] + aa))
        b.append(max(a[i] + bb, c[i] + bb))
        c.append(max(a[i] + cc, b[i] + cc))
    print((max(a[-1], b[-1], c[-1])))


main()

-n = int(eval(input())) -a = [0] -b = [0] -c = [0] -for i in range(n): -    aa, bb, cc = list(map(int, input().split())) -    a.append(max(b[i] + aa, c[i] + aa)) -    b.append(max(a[i] + bb, c[i] + bb)) -    c.append(max(a[i] + cc, b[i] + cc)) -print((max(a[-1], b[-1], c[-1]))) +def main(): +    n = int(eval(input())) +    a = [0] +    b = [0] +    c = [0] +    for i in range(n): +        aa, bb, cc = list(map(int, input().split())) +        a.append(max(b[i] + aa, c[i] + aa)) +        b.append(max(a[i] + bb, c[i] + bb)) +        c.append(max(a[i] + cc, b[i] + cc)) +    print((max(a[-1], b[-1], c[-1]))) + + +main()