JOI Junior High School has 4N first-year students, who are divided into 4 classes. The information for each class is as follows.
Next month, JOI Junior High School will hold its sports day. The sports day features various events such as relays, horse races, and stick toppling, but the dance performed by each grade is a highlight often called "the flower of the sports day."
The first-year students will select one representative from each class to form a group of 4 who will perform the dance. To make the dance look as good as possible, they decided to choose the group of 4 so that the difference in their heights is as small as possible.
Given the heights of the first-year students, write a program to find the minimum possible value of the difference between the maximum height and the minimum height among the 4 selected students.
The input is given in the following format.
N
A1 A2 … AN
B1 B2 … BN
C1 C2 … CN
D1 D2 … DN
Output the minimum possible value of the difference between the maximum height and the minimum height among the 4 selected students in one line.
1 169 173 152 200
48
Since N = 1, all students must be selected to form the group of 4. In this case, the maximum height among the 4 students is 200 and the minimum height is 152, so the difference is 200 - 152 = 48. Therefore, output 48.
7 7 9 9 4 6 3 5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
2
7 1 1 1 1 2 1 1 1 2 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 2
0
5 287 690 413 420 138 813 873 223 415 907 261 330 361 747 787 958 672 544 126 345
70
10 1682 2008 1135 1576 2450 1362 1518 1925 2212 1275 1993 1945 1312 1401 2027 1705 1086 2333 1787 1654 2257 1548 1219 1031 2613 2171 1866 1532 2800 1497 1062 1175 1984 1870 2059 1639 2107 1335 1289 2494
79
Japan Information Olympiad Committee, "22nd Japan Information Olympiad JOI 2022/2023 Second Preliminary Round Problem"