#define _CRT_SECURE_NO_WARNINGS #define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING #include using namespace std; #ifdef __GNUC__ #define WEAK __attribute__((weak)) #else #define WEAK #endif #define CRP(t, x) const t &x #define OPL(t, x) bool operator<(CRP(t, x)) const #define FIL(x, v) memset(x, v, sizeof(x)) #define CLR(x) FIL(x, 0) #define NE1(x) FIL(x, -1) #define INF(x) FIL(x, 0x3f) typedef long long ll, i64; const int N = 5050; int a[N]; struct Edge { int nxt, to; } E[N * N]; int adj[N], ecnt; inline void addEdge(int f, int t) { E[++ecnt] = {adj[f], t}; adj[f] = ecnt; } int vis[N], match[N], idx; bool hungarian(int x) { vis[x] = idx; for (int e = adj[x]; e; e = E[e].nxt) if (vis[E[e].to] != idx) if (vis[E[e].to] = idx, match[E[e].to] == -1 || hungarian(match[E[e].to])) return match[E[e].to] = x, match[x] = E[e].to, true; return false; } WEAK bool __builtin_parity(ll x) { int r = 0; for (; x; x >>= 1) r ^= x & 1; return r; } int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", a + i); sort(a, a + n); for (int i = 0; i < n; i++) for (int k = 0, *j, v; k < 31; k++) if (v = a[i] ^ (1 << k), *(j = lower_bound(a, a + n, v)) == v) addEdge(i, j - a); int ans = 0; NE1(vis), NE1(match); for (int i = 0; i < n; i++) if (match[i] == -1) ans += hungarian(idx = i); NE1(vis); for (int i = 0; i < n; i++) if (match[i] == -1 && !__builtin_parity(a[i])) hungarian(idx = i); printf("%d\n", n - ans); for (int i = 0; i < n; i++) { if (__builtin_parity(a[i]) == 0 && vis[i] != -1) printf("%d ", a[i]); if (__builtin_parity(a[i]) == 1 && vis[i] == -1) printf("%d ", a[i]); } return 0; }