#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
const int N=3e5+7;
ll T=1;
ll h[N];
ll n, oo = 1e18, k;
ll a[N], b[N], c[N];
ll dp[N][4];
ll rec(ll i, int last)
{
if(i > n)
return 0;
ll &ret = dp[i][last];
if(ret != -1)
return ret;
ret = -oo;
if(last == 1){
ret = max(ret, rec(i + 1, 2) + b[i]);
ret = max(ret, rec(i + 1, 3) + c[i]);
}
else if(last == 2){
ret = max(ret, rec(i + 1, 1) + a[i]);
ret = max(ret, rec(i + 1, 3) + c[i]);
}
else if(last == 3){
ret = max(ret, rec(i + 1, 1) + a[i]);
ret = max(ret, rec(i + 1, 2) + b[i]);
}
else{
ret = max(ret, rec(i + 1, 1) + a[i]);
ret = max(ret, rec(i + 1, 2) + b[i]);
ret = max(ret, rec(i + 1, 3) + c[i]);
}
return ret;
}
void solve()
{
memset(dp, -1, sizeof dp);
cin >> n;
for(int i = 1; i <= n; i++)
cin >> a[i] >> b[i] >> c[i];
cout << rec(1, 0);
}
int main()
{
ios::sync_with_stdio(NULL);
cin.tie(0);
cout.tie(0);
// freopen("","r", stdin);
// freopen("","w", stdout);
// cin>>T;
while(T--)
solve();
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBsbCBsb25nIGxvbmcKI2RlZmluZSBwYiBwdXNoX2JhY2sKI2RlZmluZSB5ZXMgY291dDw8IllFU1xuIjsKI2RlZmluZSBubyBjb3V0PDwiTk9cbiI7CmNvbnN0IGludCBOPTNlNSs3OwpsbCBUPTE7CmxsIGhbTl07CmxsIG4sIG9vID0gMWUxOCwgazsKbGwgYVtOXSwgYltOXSwgY1tOXTsKbGwgZHBbTl1bNF07CmxsIHJlYyhsbCBpLCBpbnQgbGFzdCkKewogICAgaWYoaSA+IG4pCiAgICAgICAgcmV0dXJuIDA7CgogICAgbGwgJnJldCA9IGRwW2ldW2xhc3RdOwoKICAgIGlmKHJldCAhPSAtMSkKICAgICAgICByZXR1cm4gcmV0OwoKICAgIHJldCA9IC1vbzsKCiAgICBpZihsYXN0ID09IDEpewogICAgICAgIHJldCA9IG1heChyZXQsIHJlYyhpICsgMSwgMikgKyBiW2ldKTsKICAgICAgICByZXQgPSBtYXgocmV0LCByZWMoaSArIDEsIDMpICsgY1tpXSk7CiAgICB9CiAgICBlbHNlIGlmKGxhc3QgPT0gMil7CiAgICAgICAgcmV0ID0gbWF4KHJldCwgcmVjKGkgKyAxLCAxKSArIGFbaV0pOwogICAgICAgIHJldCA9IG1heChyZXQsIHJlYyhpICsgMSwgMykgKyBjW2ldKTsKICAgIH0KICAgIGVsc2UgaWYobGFzdCA9PSAzKXsKICAgICAgICByZXQgPSBtYXgocmV0LCByZWMoaSArIDEsIDEpICsgYVtpXSk7CiAgICAgICAgcmV0ID0gbWF4KHJldCwgcmVjKGkgKyAxLCAyKSArIGJbaV0pOwogICAgfQogICAgZWxzZXsKICAgICAgICByZXQgPSBtYXgocmV0LCByZWMoaSArIDEsIDEpICsgYVtpXSk7CiAgICAgICAgcmV0ID0gbWF4KHJldCwgcmVjKGkgKyAxLCAyKSArIGJbaV0pOwogICAgICAgIHJldCA9IG1heChyZXQsIHJlYyhpICsgMSwgMykgKyBjW2ldKTsKICAgIH0KCiAgICByZXR1cm4gcmV0Owp9CnZvaWQgc29sdmUoKQp7CiAgICBtZW1zZXQoZHAsIC0xLCBzaXplb2YgZHApOwoKICAgIGNpbiA+PiBuOwogICAgZm9yKGludCBpID0gMTsgaSA8PSBuOyBpKyspCiAgICAgICAgY2luID4+IGFbaV0gPj4gYltpXSA+PiBjW2ldOwoKICAgIGNvdXQgPDwgcmVjKDEsIDApOwp9CmludCBtYWluKCkKewogICAgaW9zOjpzeW5jX3dpdGhfc3RkaW8oTlVMTCk7CiAgICBjaW4udGllKDApOwogICAgY291dC50aWUoMCk7CgovLyAgICBmcmVvcGVuKCIiLCJyIiwgc3RkaW4pOwovLyAgICBmcmVvcGVuKCIiLCJ3Iiwgc3Rkb3V0KTsKLy8gICAgY2luPj5UOwogICAgd2hpbGUoVC0tKQogICAgICAgIHNvbHZlKCk7CiAgICByZXR1cm4gMDsKfQo=