import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

immutable long MOD = 10^^9 + 7;

void main() {
    auto N = readln.chomp.to!int;
    auto A = N.iota.map!(_ => readln.split.map!(to!long).array).array;

    auto dp = new long[][](N+1, 3);

    foreach (i; 0..N) {
        foreach (j; 0..3) {
            foreach (k; 0..3) {
                if (j == k) continue;
                dp[i+1][k] = max(dp[i+1][k], dp[i][j] + A[i][k]);
            }
        }
    }

    dp[N].reduce!max.writeln;
}
