N = gets.to_i
a = gets.split(' ').map(&:to_i)
mx = a.max
a.sort!.reverse!.shift
t = a.max % a.min != 0 ? a.max % a.min : a.max

if (mx%a.min) == 0 && (mx%t) == 0
  puts a.min
else
  if (mx%a.min) == 0 && (mx%t) != 0
    puts (mx%t)
  elsif (mx%a.min) != 0 && (mx%t) == 0
    puts (mx%a.min)
  else
    if (mx%a.min) < (mx%t)
      puts (mx%a.min)
    else
      puts (mx%t)
    end
  end
end
