N = int(input()) A = list(map(int,input().split())) B = list(map(int,input().split())) C = [] b = 0; a = 0 #bx+a for i in range(N): temp = (A[i],B[i]) b -= B[i]; a += B[i]*A[i] C.append(temp) C.sort(key=lambda x: x[0]) #print(C) #Flag = True #負の数 #print(b,a) for i in range(N): b += 2*C[i][1] #i番目のb a -= 2*C[i][0]*C[i][1] #print(b,a) if b >= 0: ans = b*C[i][0]+a print(C[i][0],ans);exit()