#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin>>n;
vector<int> a(n),b(n),c(n);
for(int i=0;i<n;i++){
cin>>a[i]>>b[i]>>c[i];
}
vector<int>dpa(n),dpb(n),dpc(n);
dpa[0]=a[0];
dpb[0]=b[0];
dpc[0]=c[0];
for(int i=1;i<n;i++){
dpa[i]=a[i]+max(dpc[i-1],dpb[i-1]);
dpb[i]=b[i]+max(dpc[i-1],dpa[i-1]);
dpc[i]=c[i]+max(dpa[i-1],dpb[i-1]);
}
cout<<max(dpa[n-1],max(dpc[n-1],dpb[n-1]));
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiAKaW50IG1haW4oKSB7CglpbnQgbjsKCWNpbj4+bjsKCXZlY3RvcjxpbnQ+IGEobiksYihuKSxjKG4pOwoJZm9yKGludCBpPTA7aTxuO2krKyl7CgkJY2luPj5hW2ldPj5iW2ldPj5jW2ldOwoJfQoJdmVjdG9yPGludD5kcGEobiksZHBiKG4pLGRwYyhuKTsKCWRwYVswXT1hWzBdOwoJZHBiWzBdPWJbMF07CglkcGNbMF09Y1swXTsKCWZvcihpbnQgaT0xO2k8bjtpKyspewoJCWRwYVtpXT1hW2ldK21heChkcGNbaS0xXSxkcGJbaS0xXSk7CgkJZHBiW2ldPWJbaV0rbWF4KGRwY1tpLTFdLGRwYVtpLTFdKTsKCQlkcGNbaV09Y1tpXSttYXgoZHBhW2ktMV0sZHBiW2ktMV0pOwoJfQoJY291dDw8bWF4KGRwYVtuLTFdLG1heChkcGNbbi0xXSxkcGJbbi0xXSkpOwoJcmV0dXJuIDA7CiAgICAKfQ==