import bisect def main(): import sys input = sys.stdin.read data = input().split() n = int(data[0]) points = [] idx = 1 for i in range(n): x = int(data[idx]) y = int(data[idx+1]) points.append((x, y)) idx += 2 # Precompute a and b for each point sorted_a = [] sorted_b = [] for x, y in points: a = x + y b = x - y sorted_a.append((a, x, y)) sorted_b.append((b, x, y)) # Sort the lists sorted_a.sort() sorted_b.sort() # Precompute global min and max for a and b min_a = sorted_a[0][0] max_a = sorted_a[-1][0] min_b = sorted_b[0][0] max_b = sorted_b[-1][0] min_p = float('inf') for x, y in points: a = x + y b_val = x - y # Compute max_dist max_dist = max( a - min_a, max_a - a, b_val - min_b, max_b - b_val ) # Compute min_dist by checking neighbors in sorted_a and sorted_b min_dist = float('inf') # Check in sorted_a key_a = (a, x, y) idx_a = bisect.bisect_left(sorted_a, key_a) # Check up to 5 neighbors before and after start_a = max(0, idx_a - 5) end_a = min(len(sorted_a), idx_a + 6) for j in range(start_a, end_a): if j == idx_a: continue a_j, x_j, y_j = sorted_a[j] dist = abs(x - x_j) + abs(y - y_j) if dist < min_dist: min_dist = dist # Check in sorted_b key_b = (b_val, x, y) idx_b = bisect.bisect_left(sorted_b, key_b) start_b = max(0, idx_b - 5) end_b = min(len(sorted_b), idx_b + 6) for j in range(start_b, end_b): if j == idx_b: continue b_j, x_j, y_j = sorted_b[j] dist = abs(x - x_j) + abs(y - y_j) if dist < min_dist: min_dist = dist # Compute P_i p_i = abs(max_dist - min_dist) if p_i < min_p: min_p = p_i print(min_p) if __name__ == "__main__": main()