n=gets.chomp.to_i
if n == 1
  puts 0
  exit
end
ary=gets.chomp.split(' ').map(&:to_i)
cary = ary.combination(2)
tary = []
30.times do |i|
  i += 1
  tary << 2**i
end
cdt = []
cary.each do |c|
  cdt << c if tary.any? { |t| t == (c[0] + c[1]) }
end