#include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(i,n) for(int i = 0; i < n; i++) using namespace std; using namespace atcoder; using ll = long long; int main() { int n; cin >> n; vector x(n), y(n); for (int i = 0; i < n; i++) { cin >> x[i] >> y[i]; } ll ans = 1000000009; for (int i = 1; i <= 300; i++) { ll tmp = 0; for (int j = 0; j < n; j++) { tmp += abs(i - x[j]) + abs(i - y[j]); } ans = min(ans, tmp); } cout << ans << endl; }