N = gets.to_i a = gets.split(" ").map{|s| s.to_i} x = a.inject(:|) i = 1 while x & i != 0 do i <<= 1 end puts i