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

#GD0000041. Ghép xiên nướng tối ưu (BBQ Easy)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Ghép xiên nướng tối ưu (BBQ Easy)

BBQ Easy

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

There are 2n2n skewers of lengths LiL_i. Each serving uses two unused skewers and can hold as many ingredients as the shorter skewer allows. Partition all skewers into nn pairs to maximize the total capacity.

Input

Line 1: integer nn. Line 2: 2n2n integers L1,…,L2nL_1,\ldots,L_{2n}.

Output

Print the maximum total capacity.

Subtasks

  • Subtask 1 (20 points): 1≤n≤41\le n\le 4; 1≤Li≤1001\le L_i\le 100 for every 1≤i≤2n1\le i\le 2n.
  • Subtask 2 (30 points): 1≤n≤251\le n\le 25; 1≤Li≤1001\le L_i\le 100 for every 1≤i≤2n1\le i\le 2n.
  • Subtask 3 (50 points): 1≤n≤1001\le n\le 100; 1≤Li≤1001\le L_i\le 100 for every 1≤i≤2n1\le i\le 2n.

Examples

Input

2
1 3 1 2

Output

3

Explanation

The four lengths are 1, 3, 1, 2. Pairing (1,1) yields 1 and (2,3) yields 2, totaling 3, which is optimal.