if a == 2
  p b.sort[1]
else
  a1 = b[0].gcd(b[1])
  a2 = b[0].gcd(b[2])
  a3 = b[1].gcd(b[2])

  d = [a1, a2, a3].sort[2]

  ary = []
  a.times do |i|
    ary << b[i].gcd(d)
  end

  p ary.sort[1]
end