#include #include using namespace std; using namespace atcoder; using ll = long long; int main() { int N; cin >> N; vector> xy(N); for (int i = 0; i < N; i++) cin >> xy[i].first >> xy[i].second; ll ans = 1e18; for (int x = 1; x <= 300; x++) { for (int y = 1; y <= 300; y++) { ll S = 0; for (int i = 0; i < N; i++) { S += abs(x - xy[i].first) + abs(y - xy[i].second); } ans = min(ans, S); } } cout << ans << endl; return 0; }