AT_past19_j 3 人組

Description

There are $ 3N $ people numbered from $ 1 $ to $ 3N $ . Person $ i $ has $ A_i $ yen (currency in Japan). You are going to group the $ 3N $ people into $ N $ groups of three people each. Let $ S_i $ be the total amount of yen in the $ i $ -th group. Find the minimum possible $ \displaystyle \max_{1 \leq k \leq N} S_k - \min_{1 \leq k \leq N}S_k $ .

Input Format

The input is given from Standard Input in the following format: > $ N $ $ A_1 $ $ A_2 $ $ \dots $ $ A_{3N} $

Output Format

Print the minimum possible $ \displaystyle \max_{1 \leq k \leq N} S_k - \min_{1 \leq k \leq N}S_k $ .

Explanation/Hint

### Sample Explanation 1 If you group person $ 1 $ , person $ 2 $ , and person $ 6 $ into group $ 1 $ , and person $ 3 $ , person $ 4 $ , and person $ 5 $ into group $ 2 $ , then - $ S_1 = 1 + 3 + 9 = 13 $ , - $ S_2 = 4 + 6 + 2 = 12 $ , - $ \displaystyle \max_{1 \leq k \leq N} S_k - \min_{1 \leq k \leq N}S_k = 13 - 12 = 1 $ . No grouping makes $ \displaystyle \max_{1 \leq k \leq N} S_k - \min_{1 \leq k \leq N}S_k $ less than $ 1 $ , so the answer is $ 1 $ . ### Constraints - $ 2 \leq N \leq 5 $ - $ 0 \leq A_i \leq 10^8 $ - All input values are integers.