include[HTML_REMOVED]
using namespace std;
const int N = 15;
int z[N][N], f[30][N][N], a, b, c, n;
int main(){
cin>>n;
while (cin >> a >> b >> c)
z[a][b] = c;
for(int k = 2; k <= 2 * n; k)
{
for(int i = 1; i <= n; i)
{
for(int j = 1; j <= n; j++)
{
int j1 = k - i, j2 = k - j;
if(j1 >= 1 && j1 <= n && j2 >= 1 && j2 <= n)
{
int t = z[i][j1];
if(i != j) t += z[j][j2];
int &x = f[k][i][j];
x = max(x, f[k - 1][i - 1][j - 1] + t);
x = max(x, f[k - 1][i - 1][j] + t);
x = max(x, f[k - 1][i][j - 1] + t);
x = max(x, f[k - 1][i][j] + t);
}
}
}
}
cout<<f[2*n][n][n]<<endl;
}