N = int(input()) XY = [list(map(int, input().split())) for _ in range(N)] SX, SY = 0, 0 for x, y in XY: SX+=x SY+=y x = x2 = SX//N y = y2 = SY//N if SX%N!=0: x2+=1 if SY%N!=0: y2+=1 INF = 10**9 ans = INF for i in range(x, x2+1): for j in range(y, y2+1): S = 0 for sx, sy in XY: S += abs(i-sx) +abs(j-sy) ans = min(ans, S) print(ans)