import numpy as np INF = 1<<50 N = int(input()) satisf = [tuple(map(int,input().split())) for _ in range(N)] if N == 1: print(min(satisf[0])) exit() left = np.array([satisf[0][0],-satisf[0][1]]) for x,y in satisf[1:N//2]: left = np.concatenate([left + x,left - y]) right = np.array([satisf[N//2][0],-satisf[N//2][1]]) for x,y in satisf[N//2 + 1:]: right = np.concatenate([right + x,right - y]) right = np.array([-INF] + np.sort(np.unique(right)) + [INF]) idx = np.searchsorted(right,-left,'left') ans1 = np.abs(left + right[idx]).min() ans2 = np.abs(left + right[idx - 1]).min() print(min(ans1,ans2))