#include <bits/stdc++.h>   using namespace std;   const int s = 1000000;   int a[1000001];   bool belongs[1000001];   bool used[1000001];   vector<int> ans;   int main() {     int n;     cin >> n;     for (int i = 0; i <= s; i++) belongs[i] = used[i] = false;     for (int i = 0; i < n; i++) {       scanf( %i , &a[i]);       belongs[a[i]] = true;     }     int u = 1;     for (int i = 0; i < n; i++)       if (!used[a[i]]) {         if (belongs[a[i]] && !belongs[s - a[i] + 1] && !used[s - a[i] + 1]) {           ans.push_back(s - a[i] + 1);           used[s - a[i] + 1] = true;           used[a[i]] = true;         } else if (belongs[a[i]] && belongs[s - a[i] + 1]) {           while (u <= s &&                  (belongs[u] || belongs[s - u + 1] || used[u] || used[s - u + 1]))             u++;           used[u] = true;           used[s - u + 1] = true;           used[s - a[i] + 1] = true;           used[a[i]] = true;           ans.push_back(u);           ans.push_back(s - u + 1);           u++;         } else           assert(false);       }     cout << int(ans.size()) << endl;     for (int i = 0; i < int(ans.size()); i++) printf( %i  , ans[i]);     cout << endl;     return 0;   }   