//
// Created by Jorge Andrés Esguerra Alarcón on 11/28/18.
//

#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>

#include <unordered_map>
#include <unordered_set>
using namespace std;

//string s;
//getline(cin, s);

typedef long long ll; // comments that are mixed in with code
typedef pair<int, int> pii;
typedef unsigned long ull; // are aligned to the right like this
typedef vector<pii> vii;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef priority_queue<int> maxPq;
typedef priority_queue<ll, vector<ll>, greater<ll> > minPq;
typedef deque<int> dq;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define forVar(type, var, init, till, increment) for (type var = init; var < till; var += increment)
#define deb(x) cout << x << endl;
#define MAX 30
#define INF 1000000000
// Best macro definition has well established parentheses

int n;
ll a, b, c;
ll best[100010][3];

int main()
{
    cin >> n;
    vector < pair<ll, pair<ll,ll> > > nums;
    nums.push_back(MP(0, MP(0,0)));

    for (int i = 0; i < n; ++i)
    {
        cin >> a >> b >> c;
        nums.push_back(MP(a, MP(b,c)));
    }

    best[1][0] = nums[1].first;
    best[1][1] = nums[1].second.first;
    best[1][2] = nums[1].second.second;

    for (int i = 2; i <= n; ++i)
    {
        for (int j = 0; j <= 2; ++j)
        {
            ll curr = 0;
            if (j == 0)
            {
                curr = max(best[i-1][1], best[i-1][2]);
                best[i][j] = nums[i].first + curr;
            }
            else if (j == 1)
            {
                curr = max(best[i-1][0], best[i-1][2]);
                best[i][j] = nums[i].second.first + curr;
            }
            else
            {
                curr = max(best[i-1][0], best[i-1][1]);
                best[i][j] = nums[i].second.second + curr;
            }
        }
   }
   cout << max(best[n][0], max(best[n][1], best[n][2])) << endl;
   return 0;
}

Measured memory_bytes: 5744