<?php
//合成魔法が存在しない世界
fscanf(STDIN,"%d %d %d %d",$N,$A,$B,$C);
$arrayL = array();
for($i=1;$i<=$N;$i++){
  ${"l".$i} = fgets(STDIN);
  $arrayL[] = ${"l".$i};
}
$arrayL2 = $arrayL;

$nearA = 1001;
$useA = -1;
for($i=1;$i<=$N;$i++){
  $value = abs($A-$arrayL2[$i-1]);
  if($nearA > $value){
    $nearA = $value;
    $useA = $i;
  }
}
unset($arrayL2[$useA-1]);
//$arrayL2 = array_values($arrayL2);

$nearB = 1001;
$useB = -1;
for($i=1;$i<=$N;$i++){
  if(!array_key_exists($i-1,$arrayL2)){
    continue;
  }
  $value = abs($B-$arrayL2[$i-1]);
  if($nearB > $value){
    $nearB = $value;
    $useB = $i;
  }
}
unset($arrayL2[$useB-1]);

$nearC = 1001;
$useC = -1;
for($i=1;$i<=$N;$i++){
  if(!array_key_exists($i-1,$arrayL2)){
    continue;
  }
  $value = abs($C-$arrayL2[$i-1]);
  if($nearC > $value){
    $nearC = $value;
    $useC = $i;
  }
}
unset($arrayL2[$useC-1]);

echo $nearA."\n";
echo $useA."\n";
echo $nearB."\n";
echo $useB."\n";
echo $nearC."\n";
echo $useC."\n";
echo $nearA+$nearB+$nearC;
