<?php

$N = trim(fgets(STDIN));

$D = explode(' ', trim(fgets(STDIN)));

$minimum_by_takahashi = min($D);

$check_list = [];
$result_list = [];
foreach ($D as $key1 => $time1)
{
	foreach ($D as $key2 => $time2)
	{
		if ($key1 === $key2)
		{
			continue;
		}

		$self_pos = $time1;
		$self_neg = 24 - $time1;
		$target_pos = $time2;
		$target_neg = 24 - $time2;
		$pos_pos = abs($self_pos - $target_pos);
		$pos_neg = min(abs($self_pos - $target_neg), abs($self_pos + $target_pos));
		$neg_pos = min(abs($self_neg - $target_pos), abs($self_pos + $target_pos));

		$check_list[] = max([$pos_pos, $pos_neg, $neg_pos]);
	}
	if (count($check_list) === 0)
	{
		continue;
	}
	$result_list[$key1] = min($check_list);
}
$result_list[] = $minimum_by_takahashi;

echo min($result_list);
