"use strict";
function Main(input) {
    let lines = input.split("\n");
    let N = lines[0] - 0;
    let Is = new Array(N+1);
    for (let n = 1; n <= N; n++) Is[n] = lines[n].split(/\s/).map((v) => v - 0);
    Is[0] = [0, 0, 0];

    let dp = new Array(Is.length).fill(0).map((v) => [0, -1]);
    for (let n = 1; n <= N; n++) {
        for (let m = 0; m < 3; m++) {
            if (dp[n-1][1] != m) {
                let v = dp[n-1][0] + Is[n][m];
                if (dp[n][0] < v) {
                    dp[n][0] = v;
                    dp[n][1] = m;
                }
            }
        }
    }
    console.log(dp[N][0]);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
