Gutabs and sequences#11866

Gutabs and sequences

1 second
128 megabytes
Hard

In the village of Lahıc lives a famous chef named Teymur. Recently, he took part in a festival of Azerbaijani cuisine, where he presented sequences of gutabs — thin flatbreads with a variety of fillings — for the competition.

Teymur has a numerical sequence of length : a = (a_1, a_2, \dots, a_{3n}). Each number a_i represents the flavor value of the -th gutab he prepared.

Teymur wants to select exactly gutabs from this sequence by removing of them, without changing the order of the remaining ones. He will present these gutabs at the contest: the first half ( gutabs) will be placed on one side of the dish, and the second half on the other.

The score of the dish is calculated using the following formula: (sum of the flavor values in the first half) − (sum of the flavor values in the second half).

Teymur wants to achieve the highest possible score for his contest dish. Help him calculate this value.

Input

The first line contains a single integer n~(1 \le n \le 10^5).

The second line contains a sequence of integers a_1, a_2, \dots, a_{3n} of length .

Output

Print the maximum possible score that Teymur can achieve by choosing gutabs (preserving their order) and arranging them into the contest dish.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading