<?php

$length = trim(fgets(STDIN));
$cnt = 0;
$array=[];

while ($cnt < $length) {
	$input = trim(fgets(STDIN));
	$input = explode(" ", $input);
	foreach ($input as $value) {
		$array[] = $value;
		++$cnt;
	}
}

rsort($array);
$last = lcm($array[0], $array[1]);
$length = count($array);
$max = 0;

for ($i=2; $i <= $last; $i++) { 
	$tmp = 0;
	foreach ($array as $value) {
		$tmp += _mod($i, $value);
	}
	if ($max < $tmp) {
		$max = $tmp;
	}
}


out($max);

function out($var){
	echo $var , PHP_EOL;
}


function _mod($x, $y){
	return $x % $y;
}

function gcd($m, $n){
    if($n > $m) list($m, $n) = array($n, $m);
     
    while($n !== 0){
        $tmp_n = $n;
        $n = $m % $n;
        $m = $tmp_n;
    }
    return $m;
}

function lcm($m, $n){
    return $m * $n / gcd($m, $n);
}