def II() -> int : return int(input()) n = II() def solve(a): l = len(a) if l == 1: return a a0 = solve(a[:l//2]) a1 = solve(a[l//2:]) res = [] l0 = len(a0) l1 = len(a1) i0,i1 = 0,0 while i0 < l0 and i1 < l1: print("?",a0[i0],a1[i1]) if II(): res.append(a0[i0]) i0 += 1 else: res.append(a1[i1]) i1 += 1 res.extend(a0[i0:]) res.extend(a1[i1:]) return res ans = solve([*range(1,n+1)]) print("!") print(n-1) print(*ans) # print("?",1,2) # f = II() # if f: # now = [1,2] # else: # now = [2,1] # for i in range(3,n+1): # print("?",now[-1],i) # if II(): # now = now + [i] # continue # print("?",i,now[0]) # if II(): # now = [i] + now # continue # #二分探索しましょう # l = 0 # r = len(now)-1 # while r-l > 1: # mid = (l+r)//2 # print("?",now[mid],i) # f = II() # assert f != -1 # if f: # l = mid # else: # r = mid # now = now[:r] + [i] + now[r:] # print("!") # print(n-1) # print(*now)