PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GD0000024. Tích vô hướng nhỏ nhất (Minimum Scalar Product)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Tích vô hướng nhỏ nhất (Minimum Scalar Product)

Minimum Scalar Product

Source: Kattis

Version: Phuoc Hung OJ Extended

Problem Statement

Given two integer vectors of length nn, you may independently permute their elements. Find the minimum possible scalar product.

Input

The first line contains nn. The second and third lines contain vectors AA and BB.

Output

Print the minimum scalar product.

Constraints

  • 1≤n≤2⋅1051\le n\le 2\cdot10^5.
  • −109≤ai,bi≤109-10^9\le a_i,b_i\le 10^9 for 1≤i≤n1\le i\le n.

Subtasks

  • Subtask 1 (20 points): n≤8n\le 8.
  • Subtask 2 (30 points): n≤30n\le 30.
  • Subtask 3 (50 points): Full constraints.

Examples

Input

3
1 3 -5
-2 4 1

Output

-25

Explanation

The sample follows the ordering rule described in the Vietnamese explanation and produces the shown optimum.