N = int(input()) A = list(map(int,input().split())) B = list(map(int,input().split())) AB = [(a,b) for a,b in zip(A,B)] AB.sort(key=lambda x: x[0]+x[1]) NN = N+N INF = 10**18 dp = [-b for a,b in AB] for l in range(1,NN): if l%2: ndp = [INF] * (NN-l) else: ndp = [-INF] * (NN-l) for i in range(NN-l): if l%2: if i+1 < len(dp): ndp[i] = min(ndp[i], dp[i+1] + AB[i][0]) if i+l < NN: ndp[i] = min(ndp[i], dp[i] + AB[i+l][0]) else: if i+1 < len(dp): ndp[i] = max(ndp[i], dp[i+1] - AB[i][1]) if i+l < NN: ndp[i] = max(ndp[i], dp[i] - AB[i+l][1]) dp = ndp print(dp[0])