#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int a[100000];
int b[100000];
int c[100000];
int main()
{
int n;
cin >> n;
for (int i = 0; i < n; ++i)
{
cin >> a[i] >> b[i] >> c[i];
}
nth_element(a,a+n/2,a+n);
nth_element(b,b+n/2,b+n);
nth_element(c,c+n/2,c+n);
int x,y,z;
x=a[n/2];
y=b[n/2];
z=c[n/2];
long long res = 0;
for (int i = 0; i < n; ++i)
{
res += abs(a[i]-x) + abs(b[i]-y) + abs(c[i]-z);
}
cout << res << "\n";
return 0;
}