fn main() { let n: usize = { // 単一の整数を受け取り, nに束縛する let mut line: String = String::new(); std::io::stdin().read_line(&mut line).unwrap(); line.trim().parse().unwrap() }; let mut xsum = 0; let mut ysum = 0; let mut a = vec![0; n]; let mut b = vec![0; n]; for i in 0..n { let (c, d): (usize, usize) = { let mut line: String = String::new(); std::io::stdin().read_line(&mut line).unwrap(); let mut iter = line.split_whitespace(); ( iter.next().unwrap().parse().unwrap(), iter.next().unwrap().parse().unwrap() ) }; a[i] = c; b[i] = d; xsum += a[i]; ysum += b[i]; } let mut x = xsum / n; let mut y = ysum / n; if (x + 1) * n - xsum < xsum - x * n { x += 1 } if (y + 1) * n - ysum < ysum - y * n { y += 1 } let mut ans = 0; for i in 0..n { ans += (x as isize - a[i] as isize).abs(); ans += (y as isize - b[i] as isize).abs(); } println!("{}", ans); }