nction main(arg) {
  arg = arg.split("\n");
  var N = arg[0].split(" ").map(Number)[0];
  var arr = arg[1].split(" ").map(Number);
  var dp = [][]
  for (var i=0; i<N; i++) {
    for (var j=0; j<3;j++){
      for (var k=0; k<3;k++){
        dp[i] = Math.max(dp[i + 1][k], dp[i][j] + arr[i][k])
      }
    }
  }
  console.log(dp[dp.length-1])
}
main(require("fs").readFileSync("/dev/stdin", "utf8").trim()); 