#include <iostream>
#include <cstdio>
using namespace std;
long long monster_num;
long long play_w = 0LL;
long long play_m = 0LL;
long long play_j = 0LL;
struct hit
{
long long w;
long long m;
long long j;
char state;
hit(int a, int b, int c) :w(a), m(b), j(c){}
hit(){}
long long min(int a, int b)
{
return a<b ? a : b;
}
long long max(int a, int b)
{
return a>b ? a : b;
}
long long min()
{
if(w == m == j)
{
int max_num = max(play_w,max(play_m,play_j));
if (max_num == play_w)
state = 'w';
if (max_num == play_m)
state = 'm';
if (max_num == play_j)
state = 'j';
return w;
}
int min_num = min(w, min(m, j));
if (min_num == w)
state = 'w';
if (min_num == m)
state = 'm';
if (min_num == j)
state = 'j';
return min_num;
}
};
int main()
{
freopen("playwithboss.in","r",stdin);
freopen("playwithboss.out","w",stdout);
hit* hits;
cin >> monster_num;
hits = new hit[monster_num];
for (int i = 0; i<monster_num; i++)
{
int tmp_a, tmp_b, tmp_c;
cin >> tmp_a >> tmp_b >> tmp_c;
hits[i] = hit(tmp_a, tmp_b, tmp_c);
hits[i].min();
switch (hits[i].state)
{
case 'w':if (hits[i].w > play_w)
play_w = hits[i].w;
break;
case 'm':if (hits[i].m > play_m)
play_m = hits[i].m;
break;
case 'j':if (hits[i].j > play_j)
play_j = hits[i].j;
break;
};
}
long long for_out = play_w + play_m + play_j;
cout << for_out << endl;
return 0;
}