#include <iostream>
#include<fstream>
#define nmax  1000000
using namespace std;
struct {int a,b,c;}v[nmax];
int i,n,s;
ifstream f("input");
ofstream g("output");

void citire()
{ifstream f("input");
ofstream g("output");
f>>n;
for(i=1;i<=n;i++)
    f>>v[i].a>>v[i].b>>v[i].c;
}
int main()
{citire();
for(i=1;i<=n;i++)
    if(i-1<1 && i+1>n)
        s+=v[i].a;
    else
        if(i-1>=1 && i+1<=n)
            s+=v[i].c;
        else
            if(i-1>=1 || i+1<=n)
                s+=v[i].b;
g<<s;
}