Mock CCC '20 Contest 1 J5 - A Trivial Problem

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 1.0s
Memory limit: 128M

Author:
Problem type

You are given an array a of 2N integers. Can you arrange the elements in such a way as to maximize S = \displaystyle \sum_{i=1}^N |a_i - a_{i+N}|?

Input Specification

The first line will contain the integer N (1 \le N \le 10^5).

The second line will contain 2N integers, a_1, a_2, \ldots, a_{2N} (1 \le a_i \le 10^9).

Output Specification

Output the maximum value of S.

Subtasks

For 4/15 of the marks, N \le 100.

Sample Input

2
3 2 5 1

Sample Output

5

Comments

There are no comments at the moment.