Splitting into Two Teams

Given four sorted skill levels, split them into two pairs of two and print the smallest possible difference between the two pair sums.

Easy2Brute forceMathImplementationInterviewNo attempts yetTime limit2sMemory limit512 MB

Problem

Four friends are playing table tennis. Each one has a skill level written as an integer, and a larger number means a better player.

The four want to form two teams of two. To make the game more interesting, they want the skill levels of the two teams to be as close as possible. The skill level of a team is the sum of the skill levels of its two members.

They play table tennis well, but they are not good at math or computers. Find the split that makes the difference between the two team skill levels as small as possible.

Input

The first line contains four integers AA, BB, CC, DD separated by spaces, the skill levels of the four players. (0ABCD1040 \le A \le B \le C \le D \le 10^4)

Output

Print on one line the minimum difference between the two team skill levels over all ways of splitting the four players into two teams of two.