import math

from math import sqrt

import sys

from collections import deque, defaultdict

from heapq import heappop,heappush

from copy import deepcopy



INF=10**18

MOD=10**9+7

MAX=10**5+7







def main():

  N=int(eval(input()))

  dp=[[0]*3 for i in range(MAX)]

  

  for i in range(N):

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

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

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

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

  print((max(dp[N])))



if __name__=='__main__':

  main()







import math

from math import sqrt

import sys

from collections import deque, defaultdict

from heapq import heappop,heappush

from copy import deepcopy



INF=10**18

MOD=10**9+7

MAX=10**5+7







def main():

  N=int(eval(input()))

  dp=[[0]*3 for i in range(MAX)]

  

  for i in range(N):

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

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

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

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

  print((max(dp[N])))



if __name__=='__main__':

  main()







import math
from math import sqrt
import sys
from collections import deque, defaultdict
from heapq import heappop, heappush
from copy import deepcopy

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


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


if __name__ == "__main__":
    main()

import math
from math import sqrt
import sys
from collections import deque, defaultdict
from heapq import heappop, heappush
from copy import deepcopy

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


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


if __name__ == "__main__":
    main()

-        dp[i + 1][0] = max([dp[i + 1][0], dp[i][1] + a, dp[i][2] + a]) -        dp[i + 1][1] = max([dp[i + 1][1], dp[i][2] + b, dp[i][0] + b]) -        dp[i + 1][2] = max([dp[i + 1][2], dp[i][0] + c, dp[i][1] + c]) +        dp[i + 1][0] = max(dp[i][1] + a, dp[i][2] + a) +        dp[i + 1][1] = max(dp[i][2] + b, dp[i][0] + b) +        dp[i + 1][2] = max(dp[i][0] + c, dp[i][1] + c)