import java.util.Arrays;
public class Zlodeji {
private static int pocet = 3;
private static int[] pole;
private static int[] ceny;
private static int rozdiel;
public static void generuj(int odIdx) {
if (odIdx == pole.length) {
spracuj();
return;
}
for (int i = 0; i < pocet; i++) {
pole[odIdx] = i;
generuj(odIdx + 1);
}
}
public static void spracuj() {
//System.out.println(Arrays.toString(pole));
int[] lupy = new int[pocet];
for (int i = 0; i < pole.length; i++) {
lupy[pole[i]] += ceny[i];
}
int maximum = 0;
int minimum = Integer.MAX_VALUE;
for (int i = 0; i < lupy.length; i++) {
maximum = Math.max(maximum, lupy[i]);
minimum = Math.min(minimum, lupy[i]);
}
if (rozdiel > (maximum - minimum)) {
rozdiel = maximum - minimum;
}
}
public static void main(String[] args) {
ceny = new int[] { 10, 8, 2, 1, 5, 7 };
pole = new int[ceny.length];
rozdiel = Integer.MAX_VALUE;
generuj(0);
System.out.println(rozdiel);
}
}