#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define double long double
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define all(a) a.begin(),a.end()
#define sort(a) sort(all(a))
#define rsort(a) sort(all(a),greater<>())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T> inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef pair<int,int> P;
const long long MOD=1000000007;
clock_t time_ini = clock();
double time_diff(){
  ll time_tmp = clock();
  const double time = static_cast<double>(time_tmp - time_ini) / CLOCKS_PER_SEC * 1000.0;
  return time;
}
#define saiaku if(time_diff() > 1990)

vector <ll> dp_a;
vector <ll> dp_b;
vector <ll> dp_c;
vector <ll> A;
vector <ll> B;
vector <ll> C;
bool used_a;
bool used_b;
bool used_c;

ll dfs(ll i){
  if (i==0) {
    if (used_a){
      used_a = false;
      return max(B[0], C[0]);
    } else if (used_b) {
      used_b = false;
      return max(C[0], A[0]);
    } else if (used_c) {
      used_c = false;
      return max(A[0], B[0]);
    }
  }

  if (used_a) {
    used_a = false;
    if (dp_a[i]>=0) {return dp_a[i];}
    ll ans_b = 0;
    ll ans_c = 0;
    used_b = true;
    ans_b = dfs(i-1) + B[i];
    used_c = true;
    ans_c = dfs(i-1) + C[i];
    return dp_a[i] = max(ans_b, ans_c);
  } else if (used_b) {
    used_b = false;
    if (dp_b[i]>=0) {return dp_b[i];}
    ll ans_c = 0;
    ll ans_a = 0;
    used_c = true;
    ans_c = dfs(i-1) + C[i];
    used_a = true;
    ans_a = dfs(i-1) + A[i];
    return dp_b[i] = max(ans_c, ans_a);
  } else if (used_c) {
    used_c = false;
    if (dp_c[i]>=0) {return dp_c[i];}
    ll ans_a = 0;
    ll ans_b = 0;
    used_a = true;
    ans_a = dfs(i-1) + A[i];
    used_b = true;
    ans_b = dfs(i-1) + B[i];
    return dp_c[i] = max(ans_a, ans_b);
  }
}

void solve_rec_loop(long long N, std::vector<long long> a, std::vector<long long> b, std::vector<long long> c){
  dp_a = vector<ll> (N+1, -1);
  dp_b = vector<ll> (N+1, -1);
  dp_c = vector<ll> (N+1, -1);
  A = a;
  B = b;
  C = c;
  ll ans_a = 0;
  ll ans_b = 0;
  ll ans_c = 0;
  used_a = true;
  ans_a = dfs(N-1);
  used_b = true;
  ans_b = dfs(N-1);
  used_c = true;
  ans_c = dfs(N-1);
  cout << max({ans_a, ans_b, ans_c}) << endl;
}

map<string, vector<ll>> dp; 

void solve(long long N, std::vector<long long> a, std::vector<long long> b, std::vector<long long> c){
  dp["a"] = vector<ll> (N+1, 0);
  dp["b"] = vector<ll> (N+1, 0);
  dp["c"] = vector<ll> (N+1, 0);
  dp["a"][0] = a[0];
  dp["b"][0] = b[0];
  dp["c"][0] = c[0];
  for (ll i = 0; i < N; i++)
  {
    dp["a"][i+1] = a[i+1] + max(dp["b"][i], dp["c"][i]);
    dp["b"][i+1] = b[i+1] + max(dp["c"][i], dp["a"][i]);
    dp["c"][i+1] = c[i+1] + max(dp["a"][i], dp["b"][i]);
  }
  cout << max({dp["a"][N-1], dp["b"][N-1], dp["c"][N-1]}) << endl;
}

int main(){
    long long N;
    bool test = scanf("%lld",&N);
    std::vector<long long> a(N);
    std::vector<long long> b(N);
    std::vector<long long> c(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
        scanf("%lld",&c[i]);
    }
    solve(N, std::move(a), std::move(b), std::move(c));
    return 0;
}


Measured memory_bytes: 4992