"""
    Satwik_Tiwari ;) .
    28 june , 2020  - Sunday
"""

#===============================================================================================
#importing some useful libraries.
from __future__ import division, print_function

from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase

import bisect
from heapq import *
from math import *
from collections import deque
from collections import Counter as counter  # Counter(list)  return a dict with {key: count}
from itertools import combinations as comb # if a = [1,2,3] then print(list(comb(a,2))) -----> [(1, 2), (1, 3), (2, 3)]
from itertools import permutations as permutate
from bisect import bisect_left as bl
#If the element is already present in the list,
# the left most position where element has to be inserted is returned.
from bisect import bisect_right as br
from bisect import bisect
#If the element is already present in the list,
# the right most position where element has to be inserted is returned

#==============================================================================================

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

# inp = lambda: sys.stdin.readline().rstrip("\r\n")

#===============================================================================================
#some shortcuts

mod = 1000000007
def inp(): return sys.stdin.readline().rstrip("\r\n") #for fast input
def out(var): sys.stdout.write(str(var))  #for fast output, always take string
def lis(): return list(map(int, inp().split()))
def stringlis(): return list(map(str, inp().split()))
def sep(): return map(int, inp().split())
def strsep(): return map(str, inp().split())
def graph(vertex): return [[] for i in range(0,vertex+1)]
def zerolist(n): return [0]*n
def nextline(): out("\n")  #as stdout.write always print sring.
def testcase(t):
    for p in range(t):
        solve()
def printlist(a) :
    for p in range(0,len(a)):
        out(str(a[p]) + ' ')
def lcm(a,b): return (a*b)//gcd(a,b)
def power(a,b):
    ans = 1
    while(b>0):
        if(b%2==1):
            ans*=a
        a*=a
        b//=2
    return ans
def ncr(n,r): return factorial(n)//(factorial(r)*factorial(max(n-r,1)))
def isPrime(n) : # Check Prime Number or not
    if (n <= 1) : return False
    if (n <= 3) : return True
    if (n % 2 == 0 or n % 3 == 0) : return False
    i = 5
    while(i * i <= n) :
        if (n % i == 0 or n % (i + 2) == 0) :
            return False
        i = i + 6
    return True

#===============================================================================================
# code here ;))
def bs(a,l,h,x):
    while(l<h):
        # print(l,h)
        mid = (l+h)//2
        if(a[mid] == x):
            return mid
        if(a[mid] < x):
            l = mid+1
        else:
            h = mid
    return l

def sieve(a): #O(n loglogn) nearly linear
    #all odd mark 1
    for i in range(3,((10**6)+1),2):
        a[i] = 1
    #marking multiples of i form i*i 0. they are nt prime
    for i in range(3,((10**6)+1),2):
        for j in range(i*i,((10**6)+1),i):
            a[j] = 0
    a[2] = 1 #special left case
    return (a)

def bfs(g,st):
    visited = [0]*(len(g))
    visited[st] = 1
    queue = []
    queue.append(st)
    new = []
    while(len(queue) != 0):
        s = queue.pop()
        new.append(s)
        for i in g[s]:
            if(visited[i] == 0):
                visited[i] = 1
                queue.append(i)
    return new

def solve():
    n = int(inp())
    s = inp()
    cnta = 0
    cntb = 0
    ans = 0
    pre = ''
    for i in range(1,n,2):
        new = s[i-1:i+1]
        if(new == 'aa' or new == 'bb'):
            pre += 'ab'
            ans+=1
        else:
            pre += new

    print(ans)
    print(pre)

testcase(1)
# testcase(int(inp()))


n=int(input())
s=input()
x=['ab','ba']
count=0
ans=0
m_count=1000000
for i in range(0,2):
    for j in range(0,n):
        if s[j]==x[i][j%2]:
            continue
        else:
            count+=1
    if m_count<count:
        continue
    else:
        m_count=count
        ans=i
print(m_count)
for i in range(0,n//2):
    print(x[ans],end='')


n=int(input())
s=input()
x=['ab','ba']
count=0
ans=0
m_count=1000000
for i in range(0,2):
    for j in range(0,n):
        if s[j]==x[i][j%2]:
            continue
        else:
            count+=1
    if m_count<count:
        continue
    else:
        m_count=count
        ans=i
    count=0
print(m_count)
for i in range(0,n//2):
    print(x[ans],end='')


n=int(input())
s=input()
count=0
t=0
for i in range(0,n//2):
    if s[t]==s[t+1]:
        count+=1
    t+=2
print(count)
t=0
for i in range(0,n//2):
    if s[t]==s[t+1]:
        print("ab",end='')
    else:
        print(s[t]+s[t+1],end='')
    t+=2


''' بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ '''
#codeforces1216A
gi = lambda : list(map(int,input().split()))
n, = gi()
s = input()
a, b = 0, 0
ansm = 0
ss = []
for k in range(n):
    a += s[k] == "a"
    b += s[k] == "b"
    if k % 2:
        if a > b:
            ansm += 1
            a -= 1
            ss.append("b")
        elif a < b:
            ansm += 1
            b -= 1
            ss.append("a")
        else:
            ss.append(s[k])
    else:
        ss.append(s[k])
print(ansm)
print("".join(ss))


''' بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ '''
#codeforces1216A
gi = lambda : list(map(int,input().split()))
n, = gi()
s = input()
ans = 0
ss = []
for k in range(0, n, 2):
    ss.append(s[k])
    if s[k] == s[k+ 1]:
        ans += 1
        ss.append("a" if s[k] == "b" else "b")
    else:
        ss.append(s[k + 1])
print(ans)
print("".join(ss))


''' بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ '''
#codeforces1216A
gi = lambda : list(map(int,input().split()))
n, = gi()
s = input()
ss = "ab" * (n // 2)
a = [1 if s[k] != ss[k] else 0 for k in range(n)]
ss = "ba" * (n // 2)
b = [1 if s[k] != ss[k] else 0 for k in range(n)]
if sum(a) < sum(b):
    print(sum(a))
    print("ab" * (n // 2))
    exit()
print(sum(b))
print(ss)


try:
    n=int(input())
    s=input()
    c=0
    for i in range(0,n-1,2):
        x=s[i]+s[i+1]
        if x=="aa" or x=="bb":
            c+=1
    print(c)
    print("ab"*(n//2))
except EOFError:
    pass


n, s = int(input()), list(input())
ans = 0
for i in range(0, n, 2):
	if (s[i] == s[i + 1]):
		s[i] = chr(1 - ord(s[i]) + 2 * ord('a'))
		ans += 1
print(ans)
print(''.join(s))


n=int(input())
s=list(input())
i,count=1,0
while i<n:
      if s[i]==s[i-1]=="a":
            s[i]="b"
            count+=1
      if s[i]==s[i-1]=="b":
            s[i]="a"
            count+=1
      i+=2
print(count)
print(s)


n=int(input())
s=input()
i,count=1,0
while i<n:
      if s[i]==s[i-1]=="a":
            s[i]="b"
            count+=1
      if s[i]==s[i-1]=="b":
            s[i]="a"
            count+=1
      i+=2
print(count)
print(s)


n=int(input())
s=list(input())
i,count=1,0
while i<n:
      if s[i]==s[i-1]=="a":
            s[i]="b"
            count+=1
      elif s[i]==s[i-1]=="b":
            s[i]="a"
            count+=1
      i+=2
print(count)
print(*s,sep="")


n=int(input())
s=list(input())
i,count=1,0
while i<n:
      if s[i]==s[i-1]=="a":
            s[i]="b"
            count+=1
      elif s[i]==s[i-1]=="b":
            s[i]="a"
            count+=1
      i+=2
print(count)
print(s)


n = int(input())
s = input()
cnt = 0
ans = ["" for i in range(n)]
for i in range(0,n,2):
	temp = s[i:i+2]
	if temp == "aa" or temp == "bb":
		ans[i] = "a"
		ans[i+1] = "b"
		cnt += 1
	else:
		ans[i] = s[i]
		ans[i+1] = s[i+1]

print(cnt)
print("".join(ans))


n = int(input())
s = input()
cnt = 0
ans = ""
for i in range(0,n,2):
	temp = s[i:i+2]
	if temp == "aa" or temp == "bb":
		ans += "ab"
		cnt += 1
	else:
		ans += temp
print(cnt)
print(ans)


n = int(input())
s = input()
cnt = 0
ans = ""
for i in range(0,n,2):
	temp = s[i:i+2]
	if temp == "aa" or temp == "bb":
		s[i:i+2] = "ab"
		cnt += 1

print(cnt)
print(s)


n = int(input())
s = input()

t = ""
cost = 0
for i in range(0,n,2):
	c = s[i]
	d = s[i+1]
	if c == d:
		cost += 1
		t += "ab"
	else:
		t += c + d

print(cost)
print(t)


n = int(input())
s = input()

t = []
cost = 0
for i in range(0,n,2):
	c = s[i]
	d = s[i+1]
	if c == d:
		cost += 1
		t += ["a", "b"]
	else:
		t += [c, d]

print(cost)
print(''.join(t))


n = int(input())
s = input()

t = ""
cost = 0
for c, d in zip(s[::2], s[1::2]):
	if c == d:
		cost += 1
		t += "ab"
	else:
		t += c + d

print(cost)
print(t)


n = int(input())
s = input()
t = 0

for i in range(0, n, 2):
    if s[i] == s[i+1]:
        if s[i] == "a": s = s[0:i] + 'b' + s[i+1:n]
        else: s = s[0:i] + 'a' + s[i+1:n]
        t += 1

print(t)
print(s)


n=int(input())
s=input()
pref=[0]*n

for i in range(n):
    if s[i]=='b':
        pref[i]=-1
    else:
        pref[i]=1

temp=[0]*n
temp[0]=pref[0]
summ=pref[0]
for i in range(1,n):
    summ+=pref[i]
    if i%2!=0:
        temp[i]=summ
        summ=0

count=0
for i in range(1,n,2):
    if temp[i]!=0:
        count+=1

temp1=''
for i in range(n//2):
    temp1+='ab'
print(count)
print(temp1)


n=int(input())
s=input()
pref=[0]*n

for i in range(n):
    if s[i]=='b':
        pref[i]=-1
    else:
        pref[i]=1

summ,count=0,0
temp=''
for i in range(n):
    summ+=pref[i]
    if i%2!=0:
        if summ>1:
            count+=1
            summ=0
            temp+='b'
        elif summ<-1:
            count+=1
            summ=0
            temp+='a'
        else:
            temp+=s[i]
    else:
        temp+=s[i]
print(count)
print(temp)


n=int(input())
s=input()
pref=[0]*n

for i in range(n):
    if s[i]=='b':
        pref[i]=-1
    else:
        pref[i]=1

temp=[0]*n
temp[0]=pref[0]
summ=pref[0]
for i in range(1,n):
    summ+=pref[i]
    if i%2!=0:
        temp[i]=summ
        summ=0

count=0
temp1=list(s)
for i in range(1,n,2):
    if temp[i]!=0:
        count+=1
        if s[i]=='a':
            temp1[i]='b'
        elif s[i]=='b':
            temp1[i]='a'

print(count)
for i in range(n):
    print(temp1[i],end='')
print('')


n = int(input())
s = list(input())
#print(s)
cnt = 0

for i in range(1,len(s)):
  if s[i] == s[i - 1]:
    s[i] = 'a'
    s[i - 1] = 'b'
    cnt += 1

print(cnt)
print(''.join(s))


n = int(input())
s = list(input())
#print(s)
cnt = 0

for i in range(1,len(s)-1):
  if s[i] == s[i + 1]:
    s[i] = 'a'
    s[i + 1] = 'b'
    cnt += 1

print(cnt)
print(''.join(s))


n = int(input())
s = input()
cnt = 0
c = ""

for i in range(0,n//2):
  c += "ab"

for i in range(0,n):
  if s[i] != c[i]:
    cnt += 1

print(cnt)
print(c)


n = int(input())
s = list(input())
#print(s)
cnt = 0

for i in range(0,len(s),2):
  if s[i] == s[i+ 1]:
    s[i] = 'a'
    s[i + 1] = 'b'
    cnt += 1

print(cnt)
print(''.join(s))


n = int(input())
s = input()
a = []
for i in s:
    a.append(i)
cnt = 0
for i in range(0,n,2):
    if a[i]==a[i+1]:
        if a[i]=='a':
            a[i+1]='b'
        else:
            a[i+1]='a'
        cnt+=1
print(cnt)


n = int(input())
s = input()
a = []
for i in s:
    a.append(i)
cnt = 0
for i in range(0,n,2):
    if a[i]==a[i+1]:
        if a[i]=='a':
            a[i+1]='b'
        else:
            a[i+1]='a'
        cnt+=1
print(cnt)
for i in a:
    print(i,end='')


n=int(input())
s=input()
S=list(s)
ca=S.count('a')
cb=S.count('b')
if(ca==cb):
    print(0)
    print(s)
else:
    s1=''
    c=max(ca,cb)-(n//2)
    print(max(ca,cb)-(n//2))
    if(max(ca,cb)==ca):
        s = s.replace('a', 'b', c)
    else:
        s = s.replace('b', 'a', c)
    print(s)


n=int(input())
s=list(input())
c=0
for i in range(0,n,2):
    if(s[i]==s[i+1]):
        c+=1
        if(s[i]=='a'):
            s[i+1]='b'
        else:
            s[i+1]='a'
print(c)
print("".join(s))


n=int(input())
s=input()
S=list(s)
ca=S.count('a')
cb=S.count('b')
if(ca==cb):
    print(0)
    print(s)
else:
    s1=''
    c=n//2
    for i in range(n//2):
        s1+='a'
    for i in range(n//2):
        s1+='b'
    print(max(ca,cb)-(n//2))
    print(s1)


n=int(input())
s=input()
S=list(s)
ca=S.count('a')
cb=S.count('b')
if(ca==cb):
    print(0)
    print(s)
else:
    s1=''
    c=n//2
    for i in range(n//2):
        s1+='a'
        s1 += 'b'
    print(max(ca,cb)-(n//2))
    print(s1)


length = int(input())
string = input()
print(abs(string.count('a') - string.count('b')) // 2)
print("".join(["ab"] * (length // 2)))


length = int(input())
string = input()

operations = 0
altered = []

for i in range(0, length, 2):
  if string[i] == string[i + 1]:
    operations += 1
  if string[i] == 'a':
    altered.append('ab')
  else:
    altered.append('ba')

print(operations)
print("".join(altered))


length = int(input())
string = input()

print(abs(string.count('a') - string.count('b')) // 2)

altered = []
for i in range(0, length, 2):
  if string[i] == 'a':
    altered.append('ab')
  else:
    altered.append('ba')
print("".join(altered))


d = dict()
d['a'] = 'b'
d['b'] = 'a'

N = int(input())
frase = input()
new=list()
cont=0
tam = len(frase)
for i in range(0,tam,2):
	if frase[i] == frase[i+1]:
		cont+=1
		new.append(d[frase[i]])
		new.append(frase[i+1])
	else:
		new.append(frase[i])
		new.append(frase[i+1])

print(cont)
print("".join(new))


d = dict()
d['a'] = 'b'
d['b'] = 'a'

N = int(input())
frase = input()
new=''
cont=0
tam = len(frase)
for i in range(0,tam,2):
	if frase[i] == frase[i+1]:
		cont+=1
		new += d[frase[i]] + frase[i+1]
	else:
		new += frase[i] + frase[i+1]

print(cont)
print(new)


d = dict()
d['a'] = 'b'
d['b'] = 'a'

N = int(input())
frase = input()
new=''
cont=0
for i in range(0,len(frase),2):
	if frase[i] == frase[i+1]:
		cont+=1
		new += d[frase[i]] + frase[i+1]
	else:
		new += frase[i] + frase[i+1]

print(cont)
print(new)


n = int(input())
string = str(input())
new_string = ''
ans = 0
for i in range(0, n, 2):
    substring = string[i:i+2]
    if substring == 'aa' or substring == 'bb':
        ans += 1
        new_string += 'ab'
    else:
        new_string += substring
print(ans)
print(new_string)


n = int(input())
string = str(input())
new_string = ''
ans = 0
i = 0
while i < n:
    substring = string[i:i+2]
    if substring == 'aa' or substring == 'bb':
        ans += 1
        new_string += 'ab'
    else:
        new_string += substring
    i += 2
print(ans)
print(new_string)


n = int(input())
s = list(input())
ans = 0
for i in range(0, n, 2):
    if s[i] == s[i+1]:
        ans += 1
        if s[i] == 'a':
            s[i] = 'b'
        else:
            s[i] = 'a'
print(ans)
print("".join(s))


n = int(input())
string = str(input())
new_string = ''
ans = 0
for i in range(0, n, 2):
    substring = string[i:i+2]
    if substring == 'aa' or substring == 'bb':
        ans += 1
    new_string += 'ab'
print(ans)
print(new_string)


import os
import heapq
import sys
import bisect
import math
import operator
from collections import defaultdict
from io import BytesIO, IOBase

# def gcd(a,b):
#     if b==0:

#         return a
#     else:
#         return gcd(b,a%b)
def inar():
    return [int(k) for k in input().split()]
def main():
    #for _ in range(int(input())):
    n=int(input())
    #n,x,m=map(int,input().split())
    # arr=inar()
    st=list(input())
    ans=0
    for i in range(1,n,+2):
        if st[i]!=st[i-1]:
            continue
        else:
            if st[i]=="a":
                st[i]="b"
            else:
                st[i]="a"
            ans+=1
    print(ans)
    print("".join(st))

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()


import os
import heapq
import sys
import bisect
import math
import operator
from collections import defaultdict
from io import BytesIO, IOBase

# def gcd(a,b):
#     if b==0:

#         return a
#     else:
#         return gcd(b,a%b)
def inar():
    return [int(k) for k in input().split()]
def main():
    #for _ in range(int(input())):
    n=int(input())
    #n,x,m=map(int,input().split())
    # arr=inar()
    st=input()
    ans=0
    for i in range(1,n,+2):
        if st[i]!=st[i-1]:
            continue
        else:
            ans+=1
    print(ans)
    print("ab"*(n//2))

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()


n = int(input())
s = input()
b = s.count('b')
a = n - b
print(abs((n // 2) - max(a, b)))
for i in range(n // 2):
    print('ab', end = "")


n = int(input())
s = input()
b = s.count('b')
a = n - b
print(abs((n // 2) - max(a, b)))
for i in range(0, n - 1, 2):
    if (s[i] == s[i + 1]) and ((s[i] == 'b') or (s[i] == 'a')):
        print('ab', end ="")
    else:
        print(s[i] + s[i + 1], end = "")


n = int(input())
s = input()
b = s.count('b')
a = n - b
print(abs(b - a))
for i in range(n // 2):
    print('ab', end = "")


n = int(input())
s = input()
ans = list()
c = 0
for i in range(0, n - 1, 2):
    if (s[i] == s[i + 1]) and ((s[i] == 'b') or (s[i] == 'a')):
        ans.append('a')
        ans.append('b')
        c += 1
    else:
        ans.append(s[i])
        ans.append(s[i + 1])
print(c)
for i in ans:
    print(i, end = "")


n=int(input())
s=input()
A=list(s)
c=0
a=0
b=0
for i in range(0,n):
    if(A[i]=='a'):
        a+=1
    else:
        b+=1
    if(i%2!=0):
        if(a==b):
            continue
        elif(a>b):
            A[i]='b'
            c+=1
        elif(b>a):
            A[i]='a'
            c+=1
print(c)
for i in A:
    print(i,end='')


n=int(input())
s=input()
A=list(s)
c=0
for i in range(0,n,2):
    if(A[i]==A[i+1]):
        c+=1
        if(A[i]=='a'):
            A[i]='b'
        elif(A[i]=='b'):
            A[i]='a'
print(c)
for i in A:
    print(i,end='')


def solve(n, l):
    d = dict()
    l = list(l)
    a = 0
    b = 0
    ra = True
    for i in range(0, n):
        if l[i] in ['a']:
            a += 1
        else:
            b += 1

    if a == b:
        print(0)
        print("".join(l))
    else:
        counter = abs(a - b)
        ops = 0
        if abs(a-b) == n:
            counter /= 2
        if b > a:
            ra = False
        for i in range(0, n):
            if ra:
                if l[i] == 'a' and counter > 0:
                    l[i] = 'b'
                    counter -= 1
                    ops += 1
            else:
                if l[i] == 'b' and counter > 0:
                    l[i] = 'a'
                    counter -= 1
                    ops += 1
        print(ops)
        print("".join(l))

def main():
    n = int(input())
    solve(n, input())

if __name__ == "__main__":
    main()


def solve(l):
    counter = 0
    for i in range(0, len(l), 2):
        if l[i] in ['a']:
            if l[i + 1] in ['b']:
                continue
            else:
                l[i + 1] = 'b'
                counter += 1
        elif l[i] in ['b']:
            if l[i + 1] in ['a']:
                continue
            else:
                l[i + 1] = 'a'
                counter += 1
    print(counter)
    print("".join(l))

def main():
    n = int(input())
    solve(list(input()))

if __name__ == "__main__":
    main()


#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=6000010;
int a[N],vis[N],ans[N];
int s,n,m;
signed main()
{
//	freopen("sum.in","r",stdin);
//	freopen("sum.out","w",stdout);
	s=1000000;
	memset(vis,0,sizeof vis);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		vis[a[i]]=1;
	}
	int cnt=0;
	for(int i=1,j=1;i<=n;i++)
	{
		if(vis[s-a[i]+1]==0) vis[s-a[i]+1]=1,ans[++cnt]=s-ans[i]+1;
		else {
			while((vis[j]==1||vis[s-j+1]==1)) j++;
			ans[++cnt]=j,ans[++cnt]=s-j+1;
			vis[j]=vis[s-j+1]=1;
			j++;
		}
	}
	printf("%d\n",cnt);
	for(int i=1;i<=cnt;i++)
	{
		printf("%d ",ans[i]);
	}
	return 0;
}
/*
1000000
2
2 999999
*/


#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=6000010;
int a[N],vis[N],ans[N];
int s,n,m;
signed main()
{
//	freopen("sum.in","r",stdin);
//	freopen("sum.out","w",stdout);
	s=1000000;
	memset(vis,0,sizeof vis);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		vis[a[i]]=1;
	}
	int cnt=0;
	for(int i=1,j=1;i<=n;i++)
	{
		if(vis[a[i]])continue;
		if(vis[s-a[i]+1]==0) vis[s-a[i]+1]=1,ans[++cnt]=s-ans[i]+1;
		else {
			while((vis[j]==1||vis[s-j+1]==1)) j++;
			ans[++cnt]=j,ans[++cnt]=s-j+1;
			vis[s-j+1]=1;
			j++;
		}
	}
	printf("%d\n",cnt);
	for(int i=1;i<=cnt;i++)
	{
		printf("%d ",ans[i]);
	}
	return 0;
}
/*
1000000
2
2 999999
*/


#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=6000010;
int a[N],vis[N];
int s,n,ans=0,m;
signed main()
{
//	freopen("sum.in","r",stdin);
//	freopen("sum.out","w",stdout);
    s=1e6;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		vis[a[i]]=1;
	}
	cout<<n<<"\n";
	sort(a+1,a+1+n);
	int j=1;
	for(int i=1;i<=n;i++)
	{
		if(vis[s-a[i]+1]==0) vis[s-a[i]+1]=1,cout<<s-a[i]+1<<" ";
		else {
			while(vis[j]==1||vis[s-j+1]==1) j++;
			cout<<j<<" "<<s-j+1<<" ";
			vis[s-j+1]=1;
			j++;
		}
	}
	return 0;
}


#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=6000010;
int a[N],vis[N],ans[N],p[N];
int s,n,m;
signed main()
{
//	freopen("sum.in","r",stdin);
//	freopen("sum.out","w",stdout);
	s=1000000;
	memset(vis,0,sizeof vis);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		p[a[i]]=1;
	}
	int cnt=0;
	for(int i=1,j=1;i<=n;i++)
	{
		if(vis[a[i]])continue;
		if(p[s-a[i]+1]==0) ans[++cnt]=s-a[i]+1;
		else {
			while((p[j]==1||p[s-j+1]==1)) j++;
			ans[++cnt]=j,ans[++cnt]=s-j+1;
			vis[s-a[i]+1]=1;
			j++;
		}
	}
	printf("%d\n",cnt);
	for(int i=1;i<=cnt;i++)
	{
		printf("%d ",ans[i]);
	}
	return 0;
}
/*
1000000
2
2 999999
*/


#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1000010;
int a[N],vis[N];
int s,n,ans=0,m;
signed main()
{
    s=1e6;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		vis[a[i]]=1;
	}
	printf("%d\n",n);
	sort(a+1,a+1+n);
	int j=1;
	for(int i=1;i<=n;i++)
	{
		if(vis[s-a[i]+1]==0) vis[s-a[i]+1]=1,printf("%d ",s-a[i]+1);
		else {
			while((vis[j]==1||vis[s-j+1]==1)&&j<s) j++;
			printf("%d %d ",j,s-j+1);
			vis[s-j+1]=1;
			j++;
		}
	}
	return 0;
}


#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=6000010;
int a[N],vis[N],ans[N],p[N];
int s,n,m;
signed main()
{
//	freopen("sum.in","r",stdin);
//	freopen("sum.out","w",stdout);
	s=1000000;
	memset(vis,0,sizeof vis);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		p[a[i]]=1;
	}
	int cnt=0;
	for(int i=1,j=1;i<=n;i++)
	{
		if(vis[a[i]])continue;
		if(p[s-a[i]+1]==0) ans[++cnt]=s-ans[i]+1;
		else {
			while((vis[j]==1||vis[s-j+1]==1)) j++;
			ans[++cnt]=j,ans[++cnt]=s-j+1;
			vis[s-j+1]=1;
			j++;
		}
	}
	printf("%d\n",cnt);
	for(int i=1;i<=cnt;i++)
	{
		printf("%d ",ans[i]);
	}
	return 0;
}
/*
1000000
2
2 999999
*/


#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=6000010;
int a[N],vis[N];
int s,n,ans=0,m;
signed main()
{
//	freopen("sum.in","r",stdin);
//	freopen("sum.out","w",stdout);
	s=1000000;
	memset(vis,0,sizeof vis);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		vis[a[i]]=1;
	}
	printf("%d\n",n);
	int j=1;
	for(int i=1;i<=n;i++)
	{
		if(vis[s-a[i]+1]==0) vis[s-a[i]+1]=1,printf("%d ",s-a[i]+1);
		else {
			while((vis[j]==1||vis[s-j+1]==1)&&j<s-1) j++;
			if(j==1||j==0) printf("%d %d ",1,s);
			else
			printf("%d %d ",j,s-j+1);
			vis[j]=vis[s-j+1]=1;
			j++;
			i++;
		}
	}
	return 0;
}
/*
1000000
2
2 999999
*/


#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1000010;
int a[N],vis[N];
int s,n,ans=0,m;
signed main()
{
    s=1e6;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		vis[a[i]]=1;
	}
	printf("%d\n",n);
	sort(a+1,a+1+n);
	int j=1;
	for(int i=1;i<=n;i++)
	{
		if(vis[s-a[i]+1]==0) vis[s-a[i]+1]=1,printf("%d ",s-a[i]+1);
		else {
			while(vis[j]==1||vis[s-j+1]==1) j++;
			printf("%d %d ",j,s-j+1);
			vis[s-j+1]=1;
			j++;
		}
	}
	return 0;
}


#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=6000010;
int a[N],vis[N],ans[N],p[N];
int s,n,m;
signed main()
{
//	freopen("sum.in","r",stdin);
//	freopen("sum.out","w",stdout);
	s=1000000;
	memset(vis,0,sizeof vis);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		p[a[i]]=1;
	}
	int cnt=0;
	for(int i=1,j=1;i<=n;i++)
	{
		if(vis[a[i]])continue;
		if(p[s-a[i]+1]==0) ans[++cnt]=s-a[i]+1;
		else {
			while((vis[j]==1||vis[s-j+1]==1)) j++;
			ans[++cnt]=j,ans[++cnt]=s-j+1;
			vis[s-j+1]=1;
			j++;
		}
	}
	printf("%d\n",cnt);
	for(int i=1;i<=cnt;i++)
	{
		printf("%d ",ans[i]);
	}
	return 0;
}
/*
1000000
2
2 999999
*/


#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=6000010;
int a[N],vis[N];
int s,n,ans=0,m;
signed main()
{
//	freopen("sum.in","r",stdin);
//	freopen("sum.out","w",stdout);
	s=1000000;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		vis[a[i]]=1;
	}
	printf("%d\n",n);
	sort(a+1,a+1+n);
	int j=1;
	for(int i=1;i<=n;i++)
	{
		if(vis[s-a[i]+1]==0) vis[s-a[i]+1]=1,printf("%d ",s-a[i]+1);
		else {
			while((vis[j]==1||vis[s-j+1]==1)&&j<=s) j++;
			printf("%d %d ",j,s-j+1);
			vis[s-j+1]=1;
			j++;
			i++;
		}
	}
	return 0;
}
/*
1000000
2
2 999999
*/


#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=6000010;
int a[N],vis[N];
int s,n,ans=0,m;
signed main()
{
//	freopen("sum.in","r",stdin);
//	freopen("sum.out","w",stdout);
	s=1000000;
	memset(vis,0,sizeof vis);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		vis[a[i]]=1;
	}
	printf("%d\n",n);
	int j=1;
	for(int i=1;i<=n;i++)
	{
		if(vis[s-a[i]+1]==0) vis[s-a[i]+1]=1,printf("%d ",s-a[i]+1);
		else {
			while((vis[j]==1||vis[s-j+1]==1)&&j<=s) j++;
			if(s-j+1==0) printf("%d %d ",1,s);
			else
			printf("%d %d ",j,s-j+1);
			vis[j]=vis[s-j+1]=1;
			j++;
			i++;
		}
	}
	return 0;
}
/*
1000000
2
2 999999
*/


#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1000010;
int a[N],vis[N];
int s,n,ans=0,m;
signed main()
{
    s=1e6;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		vis[a[i]]=1;
	}
	printf("%d\n",n);
	sort(a+1,a+1+n);
	int j=1;
	for(int i=1;i<=n;i++)
	{
		if(vis[s-a[i]+1]==0) vis[s-a[i]+1]=1,printf("%d ",s-a[i]+1);
		else {
			while((vis[j]==1||vis[s-j+1]==1)&&j<s) j++;
			printf("%d %d ",j,s-j+1);
			vis[s-j+1]=1;
			j++;
            i++;
		}
	}
	return 0;
}


#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=6000010;
int a[N],vis[N],ans[N],p[N];
int s,n,m;
signed main()
{
//	freopen("sum.in","r",stdin);
//	freopen("sum.out","w",stdout);
	s=1000000;
	memset(vis,0,sizeof vis);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		p[a[i]]=1;
	}
	int cnt=0;
	for(int i=1,j=1;i<=n;i++)
	{
		if(vis[a[i]])continue;
		if(p[s-a[i]+1]==0) ans[++cnt]=s-a[i]+1;
		else {
			while((p[j]==1||p[s-j+1]==1)) j++;
			ans[++cnt]=j,ans[++cnt]=s-j+1;
			vis[s-j+1]=1;
			j++;
		}
	}
	printf("%d\n",cnt);
	for(int i=1;i<=cnt;i++)
	{
		printf("%d ",ans[i]);
	}
	return 0;
}
/*
1000000
2
2 999999
*/


#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1000010;
int a[N],vis[N];
int s,n,ans=0,m;
signed main()
{
    s=1e6;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		vis[a[i]]=1;
	}
	printf("%d\n",n);
	sort(a+1,a+1+n);
	int j=1;
	for(int i=1;i<=n;i++)
	{
		if(vis[s-a[i]+1]==0) vis[s-a[i]+1]=1,printf("%d ",s-a[i]+1);
		else {
			while((vis[j]==1||vis[s-j+1]==1)&&j<=s) j++;
			if(j==1)  printf("%d %d ",1,0);
			else
			printf("%d %d ",j,s-j+1);
			vis[s-j+1]=1;
			j++;
            i++;
		}
	}
	return 0;
}


#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=6000010;
int a[N],vis[N];
int s,n,ans=0,m;
signed main()
{
//	freopen("sum.in","r",stdin);
//	freopen("sum.out","w",stdout);
	s=1000000;
	memset(vis,0,sizeof vis);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		vis[a[i]]=1;
	}
	printf("%d\n",n);
	int j=1;
	for(int i=1;i<=n;i++)
	{
		if(vis[s-a[i]+1]==0) vis[s-a[i]+1]=1,printf("%d ",s-a[i]+1);
		else {
			while((vis[j]==1||vis[s-j+1]==1)&&j<s-1) j++;
			if(j==1) printf("%d %d ",1,s);
			else
			printf("%d %d ",j,s-j+1);
			vis[j]=vis[s-j+1]=1;
			j++;
			i++;
		}
	}
	return 0;
}
/*
1000000
2
2 999999
*/


#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=6000010;
int a[N],vis[N],ans[N],p[N];
int s,n,m;
signed main()
{
//	freopen("sum.in","r",stdin);
//	freopen("sum.out","w",stdout);
	s=1000000;
	memset(vis,0,sizeof vis);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		p[a[i]]=1;
	}
	int cnt=0;
	for(int i=1,j=1;i<=n;i++)
	{
		if(vis[a[i]])continue;
		if(p[s-a[i]+1]==0) vis[s-a[i]+1]=1,ans[++cnt]=s-ans[i]+1;
		else {
			while((vis[j]==1||vis[s-j+1]==1)) j++;
			ans[++cnt]=j,ans[++cnt]=s-j+1;
			vis[s-j+1]=1;
			j++;
		}
	}
	printf("%d\n",cnt);
	for(int i=1;i<=cnt;i++)
	{
		printf("%d ",ans[i]);
	}
	return 0;
}
/*
1000000
2
2 999999
*/


#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=6000010;
int a[N],vis[N];
int s,n,ans=0,m;
signed main()
{
//	freopen("sum.in","r",stdin);
//	freopen("sum.out","w",stdout);
	s=1000000;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		vis[a[i]]=1;
	}
	printf("%d\n",n);
	sort(a+1,a+1+n);
	int j=1;
	for(int i=1;i<=n;i++)
	{
		if(vis[s-a[i]+1]==0) vis[s-a[i]+1]=1,printf("%d ",s-a[i]+1);
		else {
			while((vis[j]==1||vis[s-j+1]==1)&&j<s) j++;
			if(s-j+1==0) printf("%d %d ",1,s);
			else
			printf("%d %d ",j,s-j+1);
			vis[j]=vis[s-j+1]=1;
			j++;
			i++;
		}
	}
	return 0;
}
/*
1000000
2
2 999999
*/


#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=6000010;
int a[N],vis[N];
int s,n,ans=0,m;
signed main()
{
//	freopen("sum.in","r",stdin);
//	freopen("sum.out","w",stdout);
	s=1000000;
	memset(vis,0,sizeof vis);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		vis[a[i]]=1;
	}
	printf("%d\n",n);
	int j=1;
	for(int i=1;i<=n;i++)
	{
		if(vis[s-a[i]+1]==0) vis[s-a[i]+1]=1,printf("%d ",s-a[i]+1);
		else {
			while((vis[j]==1||vis[s-j+1]==1)&&j<=s) j++;
			if(s-j+1==s) printf("%d %d ",1,0);
			else
			printf("%d %d ",j,s-j+1);
			vis[j]=vis[s-j+1]=1;
			j++;
			i++;
		}
	}
	return 0;
}
/*
1000000
2
2 999999
*/


#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=500010;
int a[N],k[N];
int s,n,ans=0,m;
map<int,int>Map;
void dfs(int sum,int num)
{
	if(sum>ans) return ;
	if(sum==ans)
	{
		cout<<num<<"\n";
		for(int i=1;i<=num;i++)
	 		cout<<k[i]<<" ";
		exit(0);
	}
	for(int i=s;i>=1;i--)
	{
		if(Map[i]==0)
		{
			k[num+1]=i;
			Map[i]=1;
			dfs(sum+s-i,num+1);
			Map[i]=0;
		}
	}
}
signed main()
{
//	freopen("sum.in","r",stdin);
//	freopen("sum.out","w",stdout);
	cin>>s>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		Map[a[i]]=1;
		ans+=a[i]-1;
	}
	dfs(0,0);
	return 0;
}


#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=6000010;
int a[N],vis[N];
int s,n,ans=0,m;
signed main()
{
//	freopen("sum.in","r",stdin);
//	freopen("sum.out","w",stdout);
	s=1000000;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		vis[a[i]]=1;
	}
	printf("%d\n",n);
	sort(a+1,a+1+n);
	int j=1;
	for(int i=1;i<=n;i++)
	{
		if(vis[s-a[i]+1]==0) vis[s-a[i]+1]=1,printf("%d ",s-a[i]+1);
		else {
			while((vis[j]==1||vis[s-j+1]==1)&&j<=s) j++;
			printf("%d %d ",j,s-j+1);
			vis[j]=vis[s-j+1]=1;
			j++;
			i++;
		}
	}
	return 0;
}
/*
1000000
2
2 999999
*/


#include<stdio.h>
using namespace std;
bool fun(bool* a,bool *b,long long sum,int init){
    if(sum==0)
        return true;
    for(int i=init;i<=1000000;i++){
        if(a[i]==0&&1000000-i<=sum){
            if(fun(a,b,sum+i-1000000,i+1)){
                b[i]=true;
                return true;
            }
        }
    }
    return false;
}
void solution(){
    int n;
    int t;
    int sum=0;
    scanf("%d",&n);
    bool a[1000005];
    bool b[1000005];
    for(int i=1;i<=1000000;i++){
        a[i]=false;
        b[i]=false;
    }
    for(int i=0;i<n;i++){
        scanf("%d",&t);
        sum+=(t-1);
        a[t]=true;
    }
    if(sum!=0)
        fun(a,b,sum,0);
    for(int i=1;i<=1000000;i++){
        if(b[i]==true)
            printf("%d ",i);
    }
    printf("1000000");
}

int main(){
    solution();
    return 0;
}


#include<stdio.h>
using namespace std;
bool fun(bool* a,bool *b,long long sum,int init){
    if(sum==0)
        return true;
    for(int i=init;i<=1000000;i++){
        if(a[i]==0&&1000000-i<=sum){
            if(fun(a,b,sum+i-1000000,i+1)){
                b[i]=true;
                return true;
            }
        }
    }
    return false;
}
void solution(){
    int n;
    int t;
    long long sum=0;
    scanf("%d",&n);
    bool a[1000005];
    bool b[1000005];
    for(int i=1;i<=1000000;i++){
        a[i]=false;
        b[i]=false;
    }
    for(int i=0;i<n;i++){
        scanf("%d",&t);
        sum+=(t-1);
        a[t]=true;
    }
    if(sum==0)
        b[1000000]=true;
    else
        fun(a,b,sum,1);
    int c=0;
    for(int i=1;i<=1000000;i++)
        if(b[i]==true)
            c++;
    printf("%d\n",c);
    for(int i=1;i<=1000000;i++){
        if(b[i]==true)
            printf("%d ",i);
    }
}

int main(){
    solution();
    return 0;
}


#include<stdio.h>
using namespace std;
bool fun(bool* a,bool *b,double sum,int init){
    if(sum==0)
        return true;
    for(int i=init;i<=1000000;i++){
        if(a[i]==0&&1000000-i<=sum){
            if(fun(a,b,sum+i-1000000,i+1)){
                b[i]=true;
                return true;
            }
        }
    }
    return false;
}
void solution(){
    int n;
    int t;
    double sum=0;
    scanf("%d",&n);
    bool a[1000005];
    bool b[1000005];
    for(int i=1;i<=1000000;i++){
        a[i]=false;
        b[i]=false;
    }
    for(int i=0;i<n;i++){
        scanf("%d",&t);
        sum+=(t-1);
        a[t]=true;
    }
    if(sum==0)
        b[1000000]=true;
    else
        fun(a,b,sum,0);
    int c=0;
    for(int i=1;i<=1000000;i++)
        if(b[i]==true)
            c++;
    printf("%d\n",c);
    for(int i=1;i<=1000000;i++){
        if(b[i]==true)
            printf("%d ",i);
    }
}

int main(){
    solution();
    return 0;
}


#include<stdio.h>
using namespace std;
bool fun(bool* a,bool *b,long long sum,int init){
    if(sum==0)
        return true;
    for(int i=init;i<=1000000;i++){
        if(a[i]==0&&1000000-i<=sum){
            if(fun(a,b,sum+i-1000000,i+1)){
                b[i]=true;
                return true;
            }
        }
    }
    return false;
}
void solution(){
    int n;
    int t;
    int sum=0;
    scanf("%d",&n);
    bool a[1000005];
    bool b[1000005];
    for(int i=1;i<=1000000;i++){
        a[i]=false;
        b[i]=false;
    }
    for(int i=0;i<n;i++){
        scanf("%d",&t);
        sum+=(t-1);
        a[t]=true;
    }
    if(sum==0)
        b[1000000]=true;
    else
        fun(a,b,sum,0);
    for(int i=1;i<=1000000;i++){
        if(b[i]==true)
            printf("%d ",i);
    }
}

int main(){
    solution();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define PB push_back
#define F first
#define S second
#define MP make_pair

#define PI acos(-1)
#define eps 1e-9
#define inf 100000000
#define MOD 1000000007
//#define harmonic(n) 0.57721566490153286l+log(n)

#define mem(a,b) memset(a, b, sizeof(a) )
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef vector<int>::iterator vit;
typedef set<int>::iterator sit;

inline bool checkBit(ll n, int i) { return n&(1LL<<i); }
inline ll setBit(ll n, int i) { return n|(1LL<<i);; }
inline ll resetBit(ll n, int i) { return n&(~(1LL<<i)); }

//int dx[] = {0, 0, +1, -1};
//int dy[] = {+1, -1, 0, 0};
//int dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};
//int dy[] = {0, +1, 0, -1, +1, -1, +1, -1};

inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
inline bool EQ2(double a, double b) {return fabs(a-b) < 1e-7; }

//
//debug
#ifdef yamin
template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
            return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
            os << "{";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << it -> first << " = " << it -> second ;
                                            }
                    return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

void faltu () {
            cerr << endl;
}

template <typename T>
void faltu( T a[], int n ) {
            for(int i = 0; i < n; ++i) cerr << a[i] << ' ';
                cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest) {
            cerr << arg << ' ';
                faltu(rest...);
}
#else
#define dbg(args...)
#endif // yamin

#define MX 1000001

set<int>store;
vi ans;

int main () {

    optimize();

    ans.PB ( MX-1 );

    int n; cin >> n;
    ll sum = 0;

    for ( int i = 0; i < MX; ++i ) store.insert ( i );

    for ( int i = 0; i < n; ++i ) {
            int num; cin >> num; store.erase ( num ); sum += num-1;
    }

    while ( sum ) {
            auto it = store.upper_bound ( sum ); --it;
            int num = *it; sum -= num; store.erase ( it );
            ans.PB ( MX-1-num );
    }

    cout << ans.size() << '\n';
    for ( int i = 0; i < ans.size(); ++i ) cout << ans[i] << " ";

    return 0;

}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define PB push_back
#define F first
#define S second
#define MP make_pair

#define PI acos(-1)
#define eps 1e-9
#define inf 100000000
#define MOD 1000000007
//#define harmonic(n) 0.57721566490153286l+log(n)

#define mem(a,b) memset(a, b, sizeof(a) )
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef vector<int>::iterator vit;
typedef set<int>::iterator sit;

inline bool checkBit(ll n, int i) { return n&(1LL<<i); }
inline ll setBit(ll n, int i) { return n|(1LL<<i);; }
inline ll resetBit(ll n, int i) { return n&(~(1LL<<i)); }

//int dx[] = {0, 0, +1, -1};
//int dy[] = {+1, -1, 0, 0};
//int dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};
//int dy[] = {0, +1, 0, -1, +1, -1, +1, -1};

inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
inline bool EQ2(double a, double b) {return fabs(a-b) < 1e-7; }

//
//debug
#ifdef yamin
template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
            return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
            os << "{";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << it -> first << " = " << it -> second ;
                                            }
                    return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

void faltu () {
            cerr << endl;
}

template <typename T>
void faltu( T a[], int n ) {
            for(int i = 0; i < n; ++i) cerr << a[i] << ' ';
                cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest) {
            cerr << arg << ' ';
                faltu(rest...);
}
#else
#define dbg(args...)
#endif // yamin

#define MX 1000001

int vis[MX+10], exist[MX+10], other[MX+10];
vi ans;

int main () {

    optimize();

    int n; cin >> n;

    for ( int i = 1; i < MX; ++i ) {
            other[i] = MX - i;
    }

    for ( int i = 0; i < n; ++i ) {
            int num; cin >> num; exist[num] = true; vis[num] = true;
    }

    for ( int i = 1, j = 1; i < MX; ++i ) {
            if ( !exist[i] ) continue;
            if ( !exist[other[i]] && !vis[other[i]] ) {
                    vis[other[i]] = true;
                    ans.PB ( other[i] );
            }
            else {
                    while ( ( vis[j] || vis[other[j]] ) && j < MX ) ++j;
                    ans.PB ( j ); ans.PB ( other[j] );
                    vis[j] = vis[other[j]] = true;
            }
    }

    cout << ans.size() << '\n';

    for ( int i = 0; i < ans.size(); ++i ) cout << ans[i] << " ";

    return 0;

}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define PB push_back
#define F first
#define S second
#define MP make_pair

#define PI acos(-1)
#define eps 1e-9
#define inf 100000000
#define MOD 1000000007
//#define harmonic(n) 0.57721566490153286l+log(n)

#define mem(a,b) memset(a, b, sizeof(a) )
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef vector<int>::iterator vit;
typedef set<int>::iterator sit;

inline bool checkBit(ll n, int i) { return n&(1LL<<i); }
inline ll setBit(ll n, int i) { return n|(1LL<<i);; }
inline ll resetBit(ll n, int i) { return n&(~(1LL<<i)); }

//int dx[] = {0, 0, +1, -1};
//int dy[] = {+1, -1, 0, 0};
//int dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};
//int dy[] = {0, +1, 0, -1, +1, -1, +1, -1};

inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
inline bool EQ2(double a, double b) {return fabs(a-b) < 1e-7; }

//
//debug
#ifdef yamin
template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
            return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
            os << "{";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << it -> first << " = " << it -> second ;
                                            }
                    return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

void faltu () {
            cerr << endl;
}

template <typename T>
void faltu( T a[], int n ) {
            for(int i = 0; i < n; ++i) cerr << a[i] << ' ';
                cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest) {
            cerr << arg << ' ';
                faltu(rest...);
}
#else
#define dbg(args...)
#endif // yamin

#define MX 1000001

int vis[MX+10], exist[MX+10], other[MX+10];
vi ans;

int main () {

    optimize();

    int n; cin >> n;

    for ( int i = 1; i < MX; ++i ) {
            other[i] = MX - i;
    }

    for ( int i = 0; i < n; ++i ) {
            int num; cin >> num; exist[num] = true; vis[num] = true;
    }

    for ( int i = 1, j = 1; i < MX; ++i ) {
            if ( !exist[i] ) continue;
            if ( !exist[other[i]] && !vis[other[i]] ) {
                    vis[other[i]] = true;
                    ans.PB ( other[i] );
            }
            else {
                    while ( !vis[j] && !vis[other[j]] && j < MX ) ++j;
                    ans.PB ( j ); ans.PB ( other[j] );
                    vis[j] = vis[other[j]] = true;
            }
    }

    cout << ans.size() << '\n';

    for ( int i = 0; i < ans.size(); ++i ) cout << ans[i] << " ";

    return 0;

}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define PB push_back
#define F first
#define S second
#define MP make_pair

#define PI acos(-1)
#define eps 1e-9
#define inf 100000000
#define MOD 1000000007
//#define harmonic(n) 0.57721566490153286l+log(n)

#define mem(a,b) memset(a, b, sizeof(a) )
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef vector<int>::iterator vit;
typedef set<int>::iterator sit;

inline bool checkBit(ll n, int i) { return n&(1LL<<i); }
inline ll setBit(ll n, int i) { return n|(1LL<<i);; }
inline ll resetBit(ll n, int i) { return n&(~(1LL<<i)); }

//int dx[] = {0, 0, +1, -1};
//int dy[] = {+1, -1, 0, 0};
//int dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};
//int dy[] = {0, +1, 0, -1, +1, -1, +1, -1};

inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
inline bool EQ2(double a, double b) {return fabs(a-b) < 1e-7; }

//
//debug
#ifdef yamin
template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
            return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
            os << "{";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << it -> first << " = " << it -> second ;
                                            }
                    return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

void faltu () {
            cerr << endl;
}

template <typename T>
void faltu( T a[], int n ) {
            for(int i = 0; i < n; ++i) cerr << a[i] << ' ';
                cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest) {
            cerr << arg << ' ';
                faltu(rest...);
}
#else
#define dbg(args...)
#endif // yamin

#define MX 1000001

set<int>store;
vi ans;

int main () {

    optimize();

    ans.PB ( MX-1 );

    int n; cin >> n;
    ll sum = 0;

    for ( int i = 0; i < MX; ++i ) store.insert ( i );

    for ( int i = 0; i < n; ++i ) {
            int num; cin >> num; store.erase ( MX-num-1 ); sum += num-1;
    }

    while ( sum > 0 ) {
            auto it = store.upper_bound ( sum ); --it;
            int num = *it; sum -= num; store.erase ( it );
            ans.PB ( MX-1-num );
    }

    cout << ans.size() << '\n';
    for ( int i = 0; i < ans.size(); ++i ) cout << ans[i] << " ";

    return 0;

}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define PB push_back
#define F first
#define S second
#define MP make_pair

#define PI acos(-1)
#define eps 1e-9
#define inf 100000000
#define MOD 1000000007
//#define harmonic(n) 0.57721566490153286l+log(n)

#define mem(a,b) memset(a, b, sizeof(a) )
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef vector<int>::iterator vit;
typedef set<int>::iterator sit;

inline bool checkBit(ll n, int i) { return n&(1LL<<i); }
inline ll setBit(ll n, int i) { return n|(1LL<<i);; }
inline ll resetBit(ll n, int i) { return n&(~(1LL<<i)); }

//int dx[] = {0, 0, +1, -1};
//int dy[] = {+1, -1, 0, 0};
//int dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};
//int dy[] = {0, +1, 0, -1, +1, -1, +1, -1};

inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
inline bool EQ2(double a, double b) {return fabs(a-b) < 1e-7; }

//
//debug
#ifdef yamin
template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
            return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
            os << "{";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << it -> first << " = " << it -> second ;
                                            }
                    return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

void faltu () {
            cerr << endl;
}

template <typename T>
void faltu( T a[], int n ) {
            for(int i = 0; i < n; ++i) cerr << a[i] << ' ';
                cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest) {
            cerr << arg << ' ';
                faltu(rest...);
}
#else
#define dbg(args...)
#endif // yamin

#define MX 1000001

int vis[MX+10], exist[MX+10], other[MX+10];
vi ans;

int main () {

    optimize();

    int n; cin >> n;

    for ( int i = 1; i < MX; ++i ) {
            other[i] = MX - i;
    }

    for ( int i = 0; i < n; ++i ) {
            int num; cin >> num; exist[num] = true; vis[num] = true;
    }

    for ( int i = 1, j = 1; i < MX; ++i ) {
            if ( !exist[i] ) continue;
            if ( !exist[other[i]] ) {
                    vis[other[i]] = true;
                    ans.PB ( other[i] );
            }
            else {
                    while ( ( vis[j] || vis[other[j]] ) && j < MX ) ++j;
                    ans.PB ( j ); ans.PB ( other[j] );
                    vis[j] = vis[other[j]] = true;
                    exist[other[i]] = false;
            }
    }

    cout << ans.size() << '\n';

    for ( int i = 0; i < ans.size(); ++i ) cout << ans[i] << " ";

    return 0;

}


#include<iostream>
#include<set>
#include<map>
#include<functional>
#include<queue>
#include<string.h>
#include <sstream>
#include<stdio.h>
#include<iomanip>
#include<stdlib.h>
#include<math.h>
#include<cstdlib>
#include<vector>
#include<random>
#include<algorithm>
#include<string>
#include<stack>
#include<queue>
#include<bitset>
#include<assert.h>
#include<fstream>
typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
#define rep(i,a,b) for (int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define sz(a) (int)a.size()
#define sqr(x) ((x) * (x))
#define pi pair<ll, ll>
#define mk(a, b) make_pair(a, b)
#define nextI nextInt()
#define nextD nextDouble()
#define nextL nextLong()
#define nextC nextChar()
#define line newLine()
#define Left(x) (2 * x + 1)
#define Right(x) (2 * x + 2)
int nextInt(){ int x; scanf("%d", &x); return x; }
double nextDouble(){ double x; scanf("%lf", &x); return x; }
ll nextLong(){ ll x; scanf("%I64d", &x); return x; }
char nextChar(){ char x; scanf("%c", &x); return x; }
void newLine(){ printf("\n"); }
ll powM(ll a, ll b, ll MOD){ ll x = 1, y = a; while (b > 0){ if (b % 2 == 1){ x = (x*y); if (x>MOD) x %= MOD; }y = (y*y); if (y>MOD) y %= MOD; b /= 2; }return x; }
int gcd(int a, int b){ return b == 0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b){ return (a*b) / gcd(a, b); }
int countBitSet(ll n){ int ans = 0;  while (n != 0){ n -= (n & -n); ++ans; } return ans; }
ll mod = ll(1e9 + 7);
ll mod2 = ll(1e9 + 9);
const int N = 1000000;
const int M = 61;
const int LOG = 21;
const int INF = 1e9;
const LD EPS = 1e-9;
const LD PI = 2 * acos(0);
using namespace std;
int used[N + 1], a[N + 1], occ[N + 1];
bool ok[N + 1];
vector<int> sol;
int main(){
#ifdef HOME
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	int n = nextI;
	for (int i = 0; i < n; i++){
		a[i] = nextI - 1;
		occ[a[i]] = 1;
	}
	int cnt = 0;
	for (int i = 0; i < n; i++){
		if (used[a[i]])continue;
		if (occ[N - a[i]]){
			used[N - a[i]] = 1;
			++cnt;
		}
		else{
			sol.push_back(N - a[i]);
			occ[N - a[i]] = 1;
		}
	}
	vector<int> v;
	for (int i = N; i > 0; i--){
		if (!occ[i]) ok[i];
	}
	sort(all(v));
	for (int i = 1; i <= N / 2; i++){
		if (cnt == 0) break;
		if (ok[i] && ok[N - i]){ cnt--; sol.push_back(N - i); sol.push_back(i); }
	}
	cout << sol.size() << endl;
	for (int i = 0; i < sol.size(); i++){
		cout << sol[i] << " ";
	}
	cout << endl;
	return 0;
}


#include<iostream>
#include<set>
#include<map>
#include<functional>
#include<queue>
#include<string.h>
#include <sstream>
#include<stdio.h>
#include<iomanip>
#include<stdlib.h>
#include<math.h>
#include<cstdlib>
#include<vector>
#include<random>
#include<algorithm>
#include<string>
#include<stack>
#include<queue>
#include<bitset>
#include<assert.h>
#include<fstream>
typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
#define rep(i,a,b) for (int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define sz(a) (int)a.size()
#define sqr(x) ((x) * (x))
#define pi pair<ll, ll>
#define mk(a, b) make_pair(a, b)
#define nextI nextInt()
#define nextD nextDouble()
#define nextL nextLong()
#define nextC nextChar()
#define line newLine()
#define Left(x) (2 * x + 1)
#define Right(x) (2 * x + 2)
int nextInt(){ int x; scanf("%d", &x); return x; }
double nextDouble(){ double x; scanf("%lf", &x); return x; }
ll nextLong(){ ll x; scanf("%I64d", &x); return x; }
char nextChar(){ char x; scanf("%c", &x); return x; }
void newLine(){ printf("\n"); }
ll powM(ll a, ll b, ll MOD){ ll x = 1, y = a; while (b > 0){ if (b % 2 == 1){ x = (x*y); if (x>MOD) x %= MOD; }y = (y*y); if (y>MOD) y %= MOD; b /= 2; }return x; }
int gcd(int a, int b){ return b == 0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b){ return (a*b) / gcd(a, b); }
int countBitSet(ll n){ int ans = 0;  while (n != 0){ n -= (n & -n); ++ans; } return ans; }
ll mod = ll(1e9 + 7);
ll mod2 = ll(1e9 + 9);
const int N = 1000000;
const int M = 61;
const int LOG = 21;
const int INF = 1e9;
const LD EPS = 1e-9;
const LD PI = 2 * acos(0);
using namespace std;
int used[N + 10], a[N + 10], occ[N + 10];
bool ok[N + 10];
vector<int> sol;
int main(){
#ifdef HOME
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	int n = nextI;
	for (int i = 0; i < n; i++){
		a[i] = nextI ;
		occ[a[i]] = 1;
	}
	int cnt = 0;
	for (int i = 0; i < n; i++){
		if (used[a[i]])continue;
		if (occ[N - a[i] + 1]){
			used[N - a[i] + 1] = 1;
			++cnt;
		}
		else{
			sol.push_back(N - a[i] + 1);
			occ[N - a[i] + 1] = 1;
		}
	}

	for (int i = N; i > 0; i--){
		if (!occ[i]) {
			ok[i] = 1;
		}
	}
	for (int i = 1; i < N / 2; i++){
		if (cnt == 0) break;
		if (ok[i] && ok[N - i + 1]){ cnt--; sol.push_back(N - i + 1); sol.push_back(i); }
	}
	cout << sol.size() << endl;
	for (int i = 0; i < sol.size(); i++){
		cout << sol[i] << " ";
	}
	cout << endl;
	return 0;
}


#include<iostream>
#include<set>
#include<map>
#include<functional>
#include<queue>
#include<string.h>
#include <sstream>
#include<stdio.h>
#include<iomanip>
#include<stdlib.h>
#include<math.h>
#include<cstdlib>
#include<vector>
#include<random>
#include<algorithm>
#include<string>
#include<stack>
#include<queue>
#include<bitset>
#include<assert.h>
#include<fstream>
typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
#define rep(i,a,b) for (int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define sz(a) (int)a.size()
#define sqr(x) ((x) * (x))
#define pi pair<ll, ll>
#define mk(a, b) make_pair(a, b)
#define nextI nextInt()
#define nextD nextDouble()
#define nextL nextLong()
#define nextC nextChar()
#define line newLine()
#define Left(x) (2 * x + 1)
#define Right(x) (2 * x + 2)
int nextInt(){ int x; scanf("%d", &x); return x; }
double nextDouble(){ double x; scanf("%lf", &x); return x; }
ll nextLong(){ ll x; scanf("%I64d", &x); return x; }
char nextChar(){ char x; scanf("%c", &x); return x; }
void newLine(){ printf("\n"); }
ll powM(ll a, ll b, ll MOD){ ll x = 1, y = a; while (b > 0){ if (b % 2 == 1){ x = (x*y); if (x>MOD) x %= MOD; }y = (y*y); if (y>MOD) y %= MOD; b /= 2; }return x; }
int gcd(int a, int b){ return b == 0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b){ return (a*b) / gcd(a, b); }
int countBitSet(ll n){ int ans = 0;  while (n != 0){ n -= (n & -n); ++ans; } return ans; }
ll mod = ll(1e9 + 7);
ll mod2 = ll(1e9 + 9);
const int N = 1000000;
const int M = 61;
const int LOG = 21;
const int INF = 1e9;
const LD EPS = 1e-9;
const LD PI = 2 * acos(0);
using namespace std;
int used[N + 1], a[N + 1], occ[N + 1];
bool ok[N + 1];
vector<int> sol;
int main(){
#ifdef HOME
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	int n = nextI;
	for (int i = 0; i < n; i++){
		a[i] = nextI - 1;
		occ[a[i]] = 1;
	}
	int cnt = 0;
	for (int i = 0; i < n; i++){
		if (used[a[i]])continue;
		if (occ[N - a[i]]){
			used[N - a[i]] = 1;
			++cnt;
		}
		else{
			sol.push_back(N - a[i]);
		}
	}
	vector<int> v;
	for (int i = N; i > 0; i--){
		if (!occ[i]) ok[i];
	}
	sort(all(v));
	for (int i = 1; i <= N / 2; i++){
		if (cnt == 0) break;
		if (ok[i] && ok[N - i]){ cnt--; sol.push_back(N - i); sol.push_back(i); }
	}
	cout << sol.size() << endl;
	for (int i = 0; i < sol.size(); i++){
		cout << sol[i] << " ";
	}
	cout << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define FOR(i, x, y) for(int i = x; i < y; i++)
#define endll cout << "\n"
#define For(n) for(int i = 0; i < n; i++)
const ll maxn = 1e6 + 100;
int x[maxn];
int is[maxn];
vector < int > vec;
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n, s = 1000000;
    scanf("%d ", &n);
    for(int i = 0; i < n; i++)
    {
        scanf("%d ", &x[i]);
        is[x[i]] ++;
    }
    int need = 0;
    for(int i = 0; i < n; i++)
    {
        if(is[s - x[i] + 1] == 0)
            vec.pb(s - x[i] + 1), is[s - x[i] + 1] = 1;
        else
            need ++;
    }
    int now = 1;
    while(need --)
    {
        while(is[now] || is[s - now + 1])
            now ++;
        vec.pb(now);
        vec.pb(s - now + 1);
        now ++;
    }
    printf("%d\n ", (int)(vec.size()));
    for(int i = 0; i < vec.size(); i++)
        printf("%d ", vec[i]);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define FOR(i, x, y) for(int i = x; i < y; i++)
#define endll cout << "\n"
#define For(n) for(int i = 0; i < n; i++)
const ll maxn = 1e6 + 100;
int x[maxn];
int is[maxn];
vector < int > vec;
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n, s = 1000000;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> x[i];
        is[x[i]] ++;
    }
    int need = 0;
    for(int i = 0; i < n; i++)
    {
        if(is[s - x[i] + 1] == 0)
            vec.pb(s - x[i] + 1), is[s - x[i] + 1] = 1;
        else if(s - x[i] + 1 < x[i])
            need ++;
    }
    int now = 1;
    while(need --)
    {
        while(is[now] || is[s - now + 1])
            now ++;
        vec.pb(now);
        vec.pb(s - now + 1);
        now ++;
    }
    cout << vec.size() << endl;
    for(int i = 0; i < vec.size(); i++)
        cout << vec[i] << ' ';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define FOR(i, x, y) for(int i = x; i < y; i++)
#define endll cout << "\n"
#define For(n) for(int i = 0; i < n; i++)
const ll maxn = 1e6 + 100;
int x[maxn];
int is[maxn];
vector < int > vec;
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n, s = 1000000;
    scanf("%d ", &n);
    for(int i = 0; i < n; i++)
    {
        scanf("%d ", &x[i]);
        is[x[i]] ++;
    }
    int need = 0;
    for(int i = 0; i < n; i++)
    {
        if(is[s - x[i] + 1] == 0)
            vec.pb(s - x[i] + 1), is[s - x[i] + 1] = 1;
        else if(s - x[i] + 1 < x[i])
            need ++;
    }
    int now = 1;
    while(need --)
    {
        while(is[now] || is[s - now + 1])
            now ++;
        vec.pb(now);
        vec.pb(s - now + 1);
        now ++;
    }
    printf("%d\n", (int)(vec.size()));
    for(int i = 0; i < vec.size(); i++)
        printf("%d ", vec[i]);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define FOR(i, x, y) for(int i = x; i < y; i++)
#define endll cout << "\n"
#define For(n) for(int i = 0; i < n; i++)
const ll maxn = 1e6 + 100;
int x[maxn];
int is[maxn];
vector < int > vec;
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n, s = 1000000;
    scanf("%d ", &n);
    for(int i = 0; i < n; i++)
    {
        scanf("%d ", &x[i]);
        is[x[i]] ++;
    }
    int need = 0;
    for(int i = 0; i < n; i++)
    {
        if(is[s - x[i] + 1] == 0)
            vec.pb(s - x[i] + 1);
        else
            need ++;
    }
    int now = 1;
    while(need --)
    {
        while(is[now] || is[s - now + 1])
            now ++;
        vec.pb(now);
        vec.pb(s - now + 1);
        now ++;
    }
    printf("%d\n ", (int)(vec.size()));
    for(int i = 0; i < vec.size(); i++)
        printf("%d ", vec[i]);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int vis[1000006];
int v[1000006];
int n, x;
long long sum;

int main(){

	scanf("%d", &n);

	for(int i = 0; i < n; i++){
		scanf("%d", v+i);
		vis[ v[i] ] = 1;
		sum += v[i]-1;
	}

	vector<int> ans;

	for(int i = 0; i < n; i++){
		if(!vis[ 1000000-v[i]+1 ]){
			sum -= v[i]-1;
			vis[1000000-v[i]+1] = 1;
			ans.push_back(1000000-v[i]+1);
		}
	}

	assert(sum % (1000000-1) == 0);

	for(int i = 1; i <= 1000000; i++){
		if(vis[i]) continue;
		if(1000000-1 <= sum){
			sum -= 1000000-1;
			ans.push_back(i);
		}

		if(!sum && ans.size()) break;
	}

	printf("%d\n", int(ans.size()));

	for(size_t i = 0; i < ans.size(); i++)
		printf("%d ", ans[i]);
	printf("\n");

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int vis[1000006];
int n, x;
long long sum;

int main(){

	scanf("%d", &n);

	for(int i = 0; i < n; i++){
		scanf("%d", &x);
		vis[x] = 1;
		sum += x-1;
	}

	vector<int> ans;

	for(int i = 1; i <= 1000000; i++){
		if(vis[i]) continue;
		if(1000000-i <= sum){
			sum -= 1000000-i;
			ans.push_back(i);
		}

		if(!sum && ans.size()) break;
	}

	printf("%d\n", int(ans.size()));

	for(size_t i = 0; i < ans.size(); i++)
		printf("%d ", ans[i]);
	printf("\n");

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int vis[1000006];
int n, x;
long long sum;

int main(){

	scanf("%d", &n);

	for(int i = 0; i < n; i++){
		scanf("%d", &x);
		vis[x] = 1;
		sum += x-1;
	}

	vector<int> ans;

	for(int i = 0; i <= 1000000; i++){
		if(1000000-i <= sum){
			sum -= 1000000-i;
			ans.push_back(i);
		}

		if(!sum && ans.size()) break;
	}

	printf("%d\n", int(ans.size()));

	for(size_t i = 0; i < ans.size(); i++)
		printf("%d ", ans[i]);
	printf("\n");

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int vis[1000006];
int v[1000006];
int n, x;
long long sum;

int main(){

	scanf("%d", &n);

	for(int i = 0; i < n; i++){
		scanf("%d", v+i);
		vis[ v[i] ] = 1;
		sum += v[i]-1;
	}

	vector<int> ans;

	for(int i = 0; i < n; i++){
		if(!vis[ 1000000-v[i]+1 ]){
			sum -= v[i]-1;
			ans.push_back(1000000-v[i]+1);
		}
	}

	for(int i = 1; i <= 1000000; i++){
		if(vis[i]) continue;
		if(1000000-i <= sum){
			sum -= 1000000-i;
			ans.push_back(i);
		}

		if(!sum && ans.size()) break;
	}

	printf("%d\n", int(ans.size()));

	for(size_t i = 0; i < ans.size(); i++)
		printf("%d ", ans[i]);
	printf("\n");

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int vis[1000006];
int v[1000006];
int n, x;
long long sum;

int main(){

	scanf("%d", &n);

	for(int i = 0; i < n; i++){
		scanf("%d", v+i);
		vis[ v[i] ] = 1;
		sum += v[i]-1;
	}

	vector<int> ans;

	for(int i = 0; i < n; i++){
		if(!vis[ 1000000-v[i]+1 ]){
			sum -= v[i]-1;
			vis[1000000-v[i]+1] = 1;
			ans.push_back(1000000-v[i]+1);
		}
	}

	assert(sum % 1000000 == 0);

	for(int i = 1; i <= 1000000; i++){
		if(vis[i]) continue;
		if(1000000-i <= sum){
			vis[i] = 1;
			vis[1000000-i+1] = 1;
			sum -= 1000000-i;
			ans.push_back(i);
		}

		if(!sum && ans.size()) break;
	}

	printf("%d\n", int(ans.size()));

	for(size_t i = 0; i < ans.size(); i++)
		printf("%d ", ans[i]);
	printf("\n");

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int vis[1000006];
int n, x;
long long sum;

int main(){

	scanf("%d", &n);

	for(int i = 0; i < n; i++){
		scanf("%d", &x);
		vis[x] = 1;
		sum += x-1;
	}

	vector<int> ans;

	for(int i = 1; i <= 1000000; i++){
		if(1000000-i <= sum){
			sum -= 1000000-i;
			ans.push_back(i);
		}

		if(!sum && ans.size()) break;
	}

	printf("%d\n", int(ans.size()));

	for(size_t i = 0; i < ans.size(); i++)
		printf("%d ", ans[i]);
	printf("\n");

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int vis[1000006];
int v[1000006];
int n, x;
long long sum;

int main(){

	scanf("%d", &n);

	for(int i = 0; i < n; i++){
		scanf("%d", v+i);
		vis[ v[i] ] = 1;
		sum += v[i]-1;
	}

	vector<int> ans;

	for(int i = 0; i < n; i++){
		if(!vis[ 1000000-v[i]+1 ]){
			sum -= v[i]-1;
			vis[1000000-v[i]+1] = 1;
			ans.push_back(1000000-v[i]+1);
		}
	}

	for(int i = 1; i <= 1000000; i++){
		if(vis[i]) continue;
		if(1000000-i <= sum){
			sum -= 1000000-i;
			ans.push_back(i);
		}

		if(!sum && ans.size()) break;
	}

	printf("%d\n", int(ans.size()));

	for(size_t i = 0; i < ans.size(); i++)
		printf("%d ", ans[i]);
	printf("\n");

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int vis[1000006];
int n, x;
long long sum;

int main(){

	scanf("%d", &n);

	for(int i = 0; i < n; i++){
		scanf("%d", &x);
		vis[x] = 1;
		sum += x-1;
	}

	vector<int> ans;

	printf("%lld\n", sum);

	for(int i = 0; i <= 1000000; i++){
		if(1000000-i <= sum){
			sum -= 1000000-i;
			ans.push_back(i);
		}

		if(!sum && ans.size()) break;
	}

	printf("%d\n", int(ans.size()));

	for(size_t i = 0; i < ans.size(); i++)
		printf("%d ", ans[i]);
	printf("\n");

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int vis[1000006];
int v[1000006];
int n, x;
long long sum;

int main(){

	scanf("%d", &n);

	for(int i = 0; i < n; i++){
		scanf("%d", v+i);
		vis[ v[i] ] = 1;
		sum += v[i]-1;
	}

	vector<int> ans;

	for(int i = 0; i < n; i++){
		if(!vis[ 1000000-v[i]+1 ]){
			sum -= v[i]-1;
			vis[1000000-v[i]+1] = 1;
			ans.push_back(1000000-v[i]+1);
		}
	}

	for(int i = 1; i <= 1000000; i++){
		if(vis[i]) continue;
		if(1000000-i <= sum){
			vis[i] = 1;
			vis[1000000-i+1] = 1;
			sum -= 1000000-i;
			ans.push_back(i);
		}

		if(!sum && ans.size()) break;
	}

	printf("%d\n", int(ans.size()));

	for(size_t i = 0; i < ans.size(); i++)
		printf("%d ", ans[i]);
	printf("\n");

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int vis[1000006];
int v[1000006];
int n, x;
long long sum;

int main(){

	scanf("%d", &n);

	for(int i = 0; i < n; i++){
		scanf("%d", v+i);
		vis[ v[i] ] = 1;
		sum += v[i]-1;
	}

	vector<int> ans;

	for(int i = 0; i < n; i++){
		if(!vis[ 1000000-v[i]+1 ]){
			sum -= v[i]-1;
			vis[1000000-v[i]+1] = 1;
			ans.push_back(1000000-v[i]+1);
		}
	}

	for(int i = 1; i <= 1000000; i++){
		if(vis[i]) continue;
		if(1000000-i <= sum){
			vis[i] = 1;
			sum -= 1000000-i;
			ans.push_back(i);
		}

		if(!sum && ans.size()) break;
	}

	printf("%d\n", int(ans.size()));

	for(size_t i = 0; i < ans.size(); i++)
		printf("%d ", ans[i]);
	printf("\n");

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int vis[1000006];
int v[1000006];
int n, x;
long long sum;

int main(){

	scanf("%d", &n);

	for(int i = 0; i < n; i++){
		scanf("%d", v+i);
		vis[ v[i] ] = 1;
		sum += v[i]-1;
	}

	vector<int> ans;

	for(int i = 0; i < n; i++){
		if(!vis[ 1000000-v[i]+1 ]){
			sum -= 1000000-v[i]+1;
			ans.push_back(v[i]+1);
		}
	}

	for(int i = 1; i <= 1000000; i++){
		if(vis[i]) continue;
		if(1000000-i <= sum){
			sum -= 1000000-i;
			ans.push_back(i);
		}

		if(!sum && ans.size()) break;
	}

	printf("%d\n", int(ans.size()));

	for(size_t i = 0; i < ans.size(); i++)
		printf("%d ", ans[i]);
	printf("\n");

	return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
using namespace std;
const int MAX = 1000001;
bool vis[MAX];
int n, p;
int main() {
    scanf("%d", &n);
    int s = MAX - 1;
    for(int i = 0, x; i < n; ++i) {
        scanf("%d", &x);
        vis[x] = 1;
        p += vis[x] && vis[s - x + 1];
    }
    int half = s << 1;
    printf("%d\n", n);
    for(int i = 1; i <= s; ++i) {
        if(!vis[i] && !vis[s - i + 1] && p) {
            --p, vis[i] = vis[s - i + 1] = 1;
            printf("%d %d ", i, s - i + 1);
        }
        else if(!vis[i] && vis[s - i + 1])
            printf("%d ", i);
    }
    puts("");
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
using namespace std;
const int MAX = 1000001;
bool vis[MAX];
int n, p;
int main() {
    scanf("%d", &n);
    for(int i = 0, x; i < n; ++i) {
        scanf("%d", &x);
        vis[x] = 1;
    }
    int s = MAX - 1;
    int half = s << 1;
    printf("%d\n", n);
    for(int i = 1; i <= s; ++i) {
        if(vis[i] && vis[s - i + 1])
            p++;
        else if(!vis[i]) {
            if(vis[s - i + 1] || p)
                printf("%d ", i);
            p -= p && !vis[s - i + 1];
        }
    }
    puts("");
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
using namespace std;
const int MAX = 1000001;
bool vis[MAX];
int n, p;
int main() {
    scanf("%d", &n);
    for(int i = 0, x; i < n; ++i) {
        scanf("%d", &x);
        vis[x] = 1;
    }
    int s = MAX - 1;
    int lim = s >> 1;
    for(int i = 1; i <= lim; ++i) {
        if(vis[i] && vis[s - i + 1])
            ++p;
        else if(vis[i])
            printf("%d ", s - i + 1);
        else if(vis[s - i - 1])
            printf("%d ", i);
        else if(p)
            printf("%d %d ", i, s - i + 1), --p;
    }
    puts("");
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
using namespace std;
const int MAX = 1000001;
bool vis[MAX];
int n, p;
int main() {
    scanf("%d", &n);
    for(int i = 0, x; i < n; ++i) {
        scanf("%d", &x);
        vis[x] = 1;
    }
    int s = MAX - 1;
    int lim = s >> 1;
    printf("%d\n", n);
    for(int i = 1; i <= lim; ++i) {
        if(vis[i] && vis[s - i + 1])
            ++p;
        else if(vis[i])
            printf("%d ", s - i + 1);
        else if(vis[s - i - 1])
            printf("%d ", i);
        else if(p)
            printf("%d %d ", i, s - i + 1), --p;
    }
    puts("");
    return 0;
}


#include <bits/stdc++.h>
#define int long long
using namespace std;
int read() {
	int x=0,f=0;
	char ch=getchar();
	while(!isdigit(ch)) f|=(ch=='-'),ch=getchar();
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}
void write(int x) {
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);
	putchar(x%10+'0');
}
const int N=1200000;
int s,n,a[N],tot,ans[N],m;
bool vis[N];
signed main() {
	s=1000000;
	n=read();
	for(int i=1; i<=n; i++) {
		a[i]=read();
		vis[a[i]]=1;
		tot+=a[i]-1;
	}
	int old=tot;
	for(int i=1; i<=s; i++) {
		if(tot==0) break;
		if(vis[i]) continue;
		if(tot>=s-i) {
			ans[++m]=i;
			tot-=(s-i);
			vis[i]=1;
		}
	}
	if(tot!=0) {
		for(int i=1;i<=m;i++) {
			if(!vis[ans[i]-tot] && ans[i]-tot>0) {
				ans[i]-=tot;
				break;
			}
		}
	}
	if(!m) {
		puts("1");
		cout<<s;
		return 0;
	}
	write(m);
	puts("");
	for(int i=1; i<=m; i++) {
		write(ans[i]);
		putchar(' ');
	}
	return 0;
}


//#include <bits/stdc++.h>
//#define int long long
//using namespace std;
//int read() {
//	int x=0,f=0;
//	char ch=getchar();
//	while(!isdigit(ch)) f|=(ch=='-'),ch=getchar();
//	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
//	return f?-x:x;
//}
//void write(int x) {
//	if(x<0) putchar('-'),x=-x;
//	if(x>=10) write(x/10);
//	putchar(x%10+'0');
//}
//const int N=1200000;
//int s,n,a[N],tot,ans[N],m;
//bool vis[N];
//signed main() {
//	freopen("sum.in","r",stdin);
//	freopen("sum.out","w",stdout);
//	s=read(),n=read();
//	for(int i=1; i<=n; i++) {
//		a[i]=read();
//		vis[a[i]]=1;
//		tot+=a[i]-1;
//	}
//	int old=tot;
//	for(int i=1; i<=s; i++) {
//		if(tot==0) break;
//		if(vis[i]) continue;
//		if(tot>=s-i) {
//			ans[++m]=i;
//			tot-=(s-i);
//		}
//	}
//	if(tot!=0) {
//		for(int i=1;i<=m;i++) {
//			if(!vis[ans[i]-tot] && ans[i]-tot>0) {
//				ans[i]-=tot;
//				break;
//			}
//		}
//	}
//	write(m);
//	puts("");
//	for(int i=1; i<=m; i++) {
//		write(ans[i]);
//		putchar(' ');
//	}
//	return 0;
//}
#include <bits/stdc++.h>
#define int long long
using namespace std;
int s,n,a[1200000],other;
bool vis[1200000];
int read() {
	int x=0,f=0;
	char ch=getchar();
	while(!isdigit(ch)) f|=(ch=='-'),ch=getchar();
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}
void write(int x) {
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);
	putchar(x%10+'0');
}
signed main() {
	s=1000000;
	cin>>n;
	for(register int i=1;i<=n;i++) {
		a[i]=read();
		vis[a[i]]=1;
	}
	cout<<n<<'\n';
	for(register int i=1;i<=s;i++) {
		if(vis[i]) {
			if(vis[s+1-i]) other++;
			else cout<<s+1-i<<" ";
		}
	}
	for(register int i=1;i<=s;i++) {
		if(!vis[i] && other && !vis[s+1-i]) {
			cout<<i<<" "<<s+1-i<<" ";
			other-=2;
		}
	}
	return 0;
}


//#include <bits/stdc++.h>
//#define int long long
//using namespace std;
//int read() {
//	int x=0,f=0;
//	char ch=getchar();
//	while(!isdigit(ch)) f|=(ch=='-'),ch=getchar();
//	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
//	return f?-x:x;
//}
//void write(int x) {
//	if(x<0) putchar('-'),x=-x;
//	if(x>=10) write(x/10);
//	putchar(x%10+'0');
//}
//const int N=1200000;
//int s,n,a[N],tot,ans[N],m;
//bool vis[N];
//signed main() {
//	freopen("sum.in","r",stdin);
//	freopen("sum.out","w",stdout);
//	s=read(),n=read();
//	for(int i=1; i<=n; i++) {
//		a[i]=read();
//		vis[a[i]]=1;
//		tot+=a[i]-1;
//	}
//	int old=tot;
//	for(int i=1; i<=s; i++) {
//		if(tot==0) break;
//		if(vis[i]) continue;
//		if(tot>=s-i) {
//			ans[++m]=i;
//			tot-=(s-i);
//		}
//	}
//	if(tot!=0) {
//		for(int i=1;i<=m;i++) {
//			if(!vis[ans[i]-tot] && ans[i]-tot>0) {
//				ans[i]-=tot;
//				break;
//			}
//		}
//	}
//	write(m);
//	puts("");
//	for(int i=1; i<=m; i++) {
//		write(ans[i]);
//		putchar(' ');
//	}
//	return 0;
//}
#include <bits/stdc++.h>
#define int long long
using namespace std;
int s,n,a[1200000],other;
bool vis[1200000];
int read() {
	int x=0,f=0;
	char ch=getchar();
	while(!isdigit(ch)) f|=(ch=='-'),ch=getchar();
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}
void write(int x) {
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);
	putchar(x%10+'0');
}
signed main()
	s=1000000;
	cin>>n;
	for(register int i=1;i<=n;i++) {
		a[i]=read();
		vis[a[i]]=1;
	}
	cout<<n<<'\n';
	for(register int i=1;i<=s;i++) {
		if(vis[i]) {
			if(vis[s+1-i]) other++;
			else cout<<s+1-i<<" ";
		}
	}
	for(register int i=1;i<=s;i++) {
		if(!vis[i] && other && !vis[s+1-i]) {
			cout<<i<<" "<<s+1-i<<" ";
			other-=2;
		}
	}
	return 0;
}


#include <bits/stdc++.h>
#define int long long
using namespace std;
int read() {
	int x=0,f=0;
	char ch=getchar();
	while(!isdigit(ch)) f|=(ch=='-'),ch=getchar();
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}
void write(int x) {
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);
	putchar(x%10+'0');
}
const int N=1200000;
int s,n,a[N],tot,ans[N],m;
bool vis[N];
signed main() {
	s=1000000;
	n=read();
	for(int i=1; i<=n; i++) {
		a[i]=read();
		vis[a[i]]=1;
		tot+=a[i]-1;
	}
	int old=tot;
	for(int i=1; i<=s; i++) {
		if(tot==0) break;
		if(vis[i]) continue;
		if(tot>=s-i) {
			ans[++m]=i;
			tot-=(s-i);
		}
	}
	if(tot!=0) {
		for(int i=1;i<=m;i++) {
			if(!vis[ans[i]-tot] && ans[i]-tot>0) {
				ans[i]-=tot;
				break;
			}
		}
	}
	write(m);
	puts("");
	for(int i=1; i<=m; i++) {
		write(ans[i]);
		putchar(' ');
	}
	return 0;
}


#include <bits/stdc++.h>
#define int long long
using namespace std;
int read() {
	int x=0,f=0;
	char ch=getchar();
	while(!isdigit(ch)) f|=(ch=='-'),ch=getchar();
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}
void write(int x) {
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);
	putchar(x%10+'0');
}
const int N=1200000;
int s,n,a[N],tot,ans[N],m;
bool vis[N];
signed main() {
	s=1000000;
	n=read();
	for(int i=1; i<=n; i++) {
		a[i]=read();
		vis[a[i]]=1;
		tot+=a[i]-1;
	}
	int old=tot;
	for(int i=1; i<=s; i++) {
		if(tot==0) break;
		if(vis[i]) continue;
		if(tot>=s-i) {
			ans[++m]=i;
			tot-=(s-i);
		}
	}
	if(tot!=0) {
		for(int i=1;i<=m;i++) {
			if(!vis[ans[i]-tot] && ans[i]-tot>0) {
				ans[i]-=tot;
				break;
			}
		}
	}
	if(!m) {
		puts("1");
		cout<<s;
		return 0;
	}
	write(m);
	puts("");
	for(int i=1; i<=m; i++) {
		write(ans[i]);
		putchar(' ');
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define dd ch=getchar()
inline int read()
{
	int x=0;bool f=false;char dd;
	while(!isdigit(ch))f|=ch=='-',dd;
	while(isdigit(ch))x=(x<<1)+(x<<3)+ch-48,dd;
	return f?-x:x;
}
#undef dd
void write(int x)
{
	if(x<0)x=-x,putchar('-');
	if(x>9)write(x/10);
	putchar(x%10+48);
}

const int M=1000005;
int n,s,sum=0;
bool vis[M];
vector<int>ans;

int main()
{
	s=read(),n=read();
	for(int i=1;i<=n;i++)
		vis[read()-1]=true;
	int cnt=0;
	for(int i=0;i<=s>>1;i++)
	{
		int ak=s-i;
		if(vis[i]&&vis[ak])cnt++;
		else if(vis[i]&&!vis[ak])
		{
			vis[ak]=true;
			ans.push_back(ak);
		}
		else if(!vis[i]&&vis[ak])
		{
			vis[i]=true;
			ans.push_back(i);
		}
	}
	for(int i=0;i<=s>>1;i++)
	{
		int ak=s-i;
		if(!vis[i]&&!vis[ak]&&cnt)
		{
			cnt--;
			vis[i]=vis[ak]=true;
			ans.push_back(i);
			ans.push_back(ak);
		}
	}
	write(ans.size()),putchar('\n');
	for(int i=0;i<(int)ans.size();i++)
		write(ans[i]),putchar(' ');
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define dd ch=getchar()
inline int read()
{
	int x=0;bool f=false;char dd;
	while(!isdigit(ch))f|=ch=='-',dd;
	while(isdigit(ch))x=(x<<1)+(x<<3)+ch-48,dd;
	return f?-x:x;
}
#undef dd
void write(int x)
{
	if(x<0)x=-x,putchar('-');
	if(x>9)write(x/10);
	putchar(x%10+48);
}

const int M=1000005;
int n,s,sum=0;
bool vis[M];
vector<int>ans;

int main()
{
//	freopen("sum.in","r",stdin);
//	freopen("sum.out","w",stdout);
	n=read();s=1e6;
	for(int i=1;i<=n;i++)
		vis[read()-1]=true;
	int cnt=0;
	for(int i=0;i<=s>>1;i++)
	{
		int ak=s-i;
		if(vis[i]&&vis[ak])cnt++;
		else if(vis[i]&&!vis[ak])
		{
			vis[ak]=true;
			ans.push_back(ak);
		}
		else if(!vis[i]&&vis[ak])
		{
			vis[i]=true;
			ans.push_back(i);
		}
	}
	for(int i=0;i<=s>>1;i++)
	{
		int ak=s-i;
		if(!vis[i]&&!vis[ak]&&cnt)
		{
			cnt--;
			vis[i]=vis[ak]=true;
			ans.push_back(i);
			ans.push_back(ak);
		}
	}
	write(ans.size()),putchar('\n');
	for(int i=0;i<(int)ans.size();i++)
		write(ans[i]),putchar(' ');
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define dd ch=getchar()
inline int read()
{
	int x=0;bool f=false;char dd;
	while(!isdigit(ch))f|=ch=='-',dd;
	while(isdigit(ch))x=(x<<1)+(x<<3)+ch-48,dd;
	return f?-x:x;
}
#undef dd
void write(int x)
{
	if(x<0)x=-x,putchar('-');
	if(x>9)write(x/10);
	putchar(x%10+48);
}

const int M=1000005;
int n,s,sum=0;
bool vis[M];
int a[M>>1];
vector<int>ans;

int main()
{
//	freopen("sum.in","r",stdin);
//	freopen("sum.out","w",stdout);
	s=read();n=read();
	for(int i=1;i<=n;i++)
		a[i]=read(),vis[a[i]]=true;
	int cnt=0;
	for(int i=1;i<=n;i++)
	{
		int ak=s-a[i]+1;
		if(vis[ak])cnt++;
		else ans.push_back(ak);
	}
	for(int i=1;i<=s>>1;i++)
	{
		int ak=s-i+1;
		if(!vis[i]&&!vis[ak]&&cnt)
		{
			cnt-=2;
			vis[i]=vis[ak]=true;
			ans.push_back(i);
			ans.push_back(ak);
		}
	}
	write(ans.size()),putchar('\n');
	for(int i=0;i<(int)ans.size();i++)
		write(ans[i]),putchar(' ');
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define dd ch=getchar()
inline int read()
{
	int x=0;bool f=false;char dd;
	while(!isdigit(ch))f|=ch=='-',dd;
	while(isdigit(ch))x=(x<<1)+(x<<3)+ch-48,dd;
	return f?-x:x;
}
#undef dd
void write(int x)
{
	if(x<0)x=-x,putchar('-');
	if(x>9)write(x/10);
	putchar(x%10+48);
}

const int M=1000005;
int n,s,sum=0;
bool vis[M];
int a[M>>1];
vector<int>ans;

int main()
{
//	freopen("sum.in","r",stdin);
//	freopen("sum.out","w",stdout);
	s=1e6;n=read();
	for(int i=1;i<=n;i++)
		a[i]=read(),vis[a[i]]=true;
	int cnt=0;
	for(int i=1;i<=n;i++)
	{
		int ak=s-a[i]+1;
		if(vis[ak])cnt++;
		else ans.push_back(ak);
	}
	for(int i=1;i<=s>>1;i++)
	{
		int ak=s-i+1;
		if(!vis[i]&&!vis[ak]&&cnt)
		{
			cnt-=2;
			vis[i]=vis[ak]=true;
			ans.push_back(i);
			ans.push_back(ak);
		}
	}
	write(ans.size()),putchar('\n');
	for(int i=0;i<(int)ans.size();i++)
		write(ans[i]),putchar(' ');
	return 0;
}


/*
          ______
||  //   | _____|   ||  //
|| //    ||         || //
||//     ||_____    ||//
||\\     | _____|   ||\\
|| \\    ||         || \\   ll Once(ll KEK){
||  \\   ||_____    ||  \\ 		return Forever(KEK);
||   \\  |______|   ||   \\ }

*/
#include<bits/stdc++.h>

using namespace std;
const int N6 = 2e6 + 6, N3 = 1e3 + 6, oo =  1e9 + 9, base = 1e9 + 7;
const long long ool = 1e18 + 9;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;

#define F first
#define S second
#define pb push_back
#define right(x) x << 1 | 1
#define left(x) x << 1
#define	forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)
#define mp make_pair

int n;
ll sum, a[N6];
bool u[N6];
vector <ll> ans;

int main(){
	ios_base :: sync_with_stdio(0);
	cin.tie(0);

	cin >> n;
	forn(i, 1, n){
		cin >> a[i];
		u[a[i]] = 1;
	}

	int N = (int)1e6;

	forn(i, 1, n){
		if(u[N - a[i] + 1])
			sum += a[i] - 1;
		else{
			u[N - a[i] + 1] = 1;
			ans.pb(N - a[i] + 1);
		}
	}

	forn(i, 1, N){
		if(u[i] || sum - (N - i) < 0)
			continue;
		sum -= (N - i);
		ans.pb(i);
	}

	cout << (int)ans.size() << "\n";
	for(auto it : ans)
		cout << it << " ";

	return 0;
}


/*
          ______
||  //   | _____|   ||  //
|| //    ||         || //
||//     ||_____    ||//
||\\     | _____|   ||\\
|| \\    ||         || \\   ll Once(ll KEK){
||  \\   ||_____    ||  \\ 		return Forever(KEK);
||   \\  |______|   ||   \\ }

*/
#include<bits/stdc++.h>

using namespace std;
const int N6 = 2e6 + 6, N3 = 1e3 + 6, oo =  1e9 + 9, base = 1e9 + 7;
const long long ool = 1e18 + 9;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;

#define F first
#define S second
#define pb push_back
#define right(x) x << 1 | 1
#define left(x) x << 1
#define	forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)
#define mp make_pair

int n;
ll sum;
bool u[N6];
vector <int> ans;

int main(){
	ios_base :: sync_with_stdio(0);
	cin.tie(0);

	cin >> n;
	forn(i, 1, n){
		int x;
		cin >> x;
		u[x] = 1;
		sum += x - 1;
	}

	forn(i, 1, int(1e6)){
		if(u[i] || sum - (int(1e6) - i) < 0)
			continue;
		sum -= (int(1e6) - i);
		ans.pb(i);
	}

	cout << (int)ans.size() << "\n";
	for(auto it : ans)
		cout << it << " ";

	return 0;
}


/*
          ______
||  //   | _____|   ||  //
|| //    ||         || //
||//     ||_____    ||//
||\\     | _____|   ||\\
|| \\    ||         || \\   ll Once(ll KEK){
||  \\   ||_____    ||  \\ 		return Forever(KEK);
||   \\  |______|   ||   \\ }

*/
#include<bits/stdc++.h>

using namespace std;
const int N6 = 2e6 + 6, N3 = 1e3 + 6, oo =  1e9 + 9, base = 1e9 + 7;
const long long ool = 1e18 + 9;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;

#define F first
#define S second
#define pb push_back
#define right(x) x << 1 | 1
#define left(x) x << 1
#define	forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)
#define mp make_pair

int n;
ll sum;
bool u[N6];
vector <ll> ans;

int main(){
	ios_base :: sync_with_stdio(0);
	cin.tie(0);

	cin >> n;
	forn(i, 1, n){
		ll x;
		cin >> x;
		u[x] = 1;
		sum += x - 1;
	}

	forn(i, 1, int(1e6)){
		if(u[i] || sum - (int(1e6) - i) < 0)
			continue;
		sum -= (int(1e6) - i);
		if(sum - i >= 0){
			sum -= i;
			ans.pb((int)1e6 - i);
		}
		ans.pb(i);
	}

	cout << (int)ans.size() << "\n";
	for(auto it : ans)
		cout << it << " ";

	return 0;
}


/*
          ______
||  //   | _____|   ||  //
|| //    ||         || //
||//     ||_____    ||//
||\\     | _____|   ||\\
|| \\    ||         || \\   ll Once(ll KEK){
||  \\   ||_____    ||  \\ 		return Forever(KEK);
||   \\  |______|   ||   \\ }

*/
#include<bits/stdc++.h>

using namespace std;
const int N6 = 2e6 + 6, N3 = 1e3 + 6, oo =  1e9 + 9, base = 1e9 + 7;
const long long ool = 1e18 + 9;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;

#define F first
#define S second
#define pb push_back
#define right(x) x << 1 | 1
#define left(x) x << 1
#define	forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)
#define mp make_pair

int n;
ll sum, a[N6];
bool u[N6];
vector <ll> ans;

int main(){
	ios_base :: sync_with_stdio(0);
	cin.tie(0);

	cin >> n;
	forn(i, 1, n){
		cin >> a[i];
		u[a[i]] = 1;
	}

	int N = (int)1e6;

	forn(i, 1, n){
		if(u[N - a[i] + 1])
			sum += a[i] - 1;
		else{
			u[N - a[i] + 1] = 1;
			ans.pb(N - a[i] + 1);
		}
	}

	forn(i, 1, N){
		if(u[i] || sum - (N - i) - i + 1 < 0)
			continue;
		sum -= (N - i) - i + 1;
		ans.pb(i);
		ans.pb(N - i + 1);
	}

	cout << (int)ans.size() << "\n";
	for(auto it : ans)
		cout << it << " ";

	return 0;
}


/*
          ______
||  //   | _____|   ||  //
|| //    ||         || //
||//     ||_____    ||//
||\\     | _____|   ||\\
|| \\    ||         || \\   ll Once(ll KEK){
||  \\   ||_____    ||  \\ 		return Forever(KEK);
||   \\  |______|   ||   \\ }

*/
#include<bits/stdc++.h>

using namespace std;
const int N6 = 2e6 + 6, N3 = 1e3 + 6, oo =  1e9 + 9, base = 1e9 + 7;
const long long ool = 1e18 + 9;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;

#define F first
#define S second
#define pb push_back
#define right(x) x << 1 | 1
#define left(x) x << 1
#define	forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)
#define mp make_pair

int n;
ll sum;
bool u[N6];
vector <ll> ans;

int main(){
	ios_base :: sync_with_stdio(0);
	cin.tie(0);

	cin >> n;
	forn(i, 1, n){
		ll x;
		cin >> x;
		u[x] = 1;
		sum += x - 1;
	}

	forn(i, 1, int(1e6)){
		if(u[i] || sum - (int(1e6) - i) < 0)
			continue;
		sum -= (int(1e6) - i);
		if(!u[(int)1e6 - i] && sum - i >= 0){
			sum -= i;
			ans.pb((int)1e6 - i);
		}
		ans.pb(i);
	}

	cout << (int)ans.size() << "\n";
	for(auto it : ans)
		cout << it << " ";

	return 0;
}


/*
          ______
||  //   | _____|   ||  //
|| //    ||         || //
||//     ||_____    ||//
||\\     | _____|   ||\\
|| \\    ||         || \\   ll Once(ll KEK){
||  \\   ||_____    ||  \\ 		return Forever(KEK);
||   \\  |______|   ||   \\ }

*/
#include<bits/stdc++.h>

using namespace std;
const int N6 = 2e6 + 6, N3 = 1e3 + 6, oo =  1e9 + 9, base = 1e9 + 7;
const long long ool = 1e18 + 9;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;

#define F first
#define S second
#define pb push_back
#define right(x) x << 1 | 1
#define left(x) x << 1
#define	forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)
#define mp make_pair

int n;
ll sum, a[N6];
bool u[N6];
vector <ll> ans;

int main(){
	ios_base :: sync_with_stdio(0);
	cin.tie(0);

	cin >> n;
	forn(i, 1, n){
		cin >> a[i];
		u[a[i]] = 1;
	}

	int N = (int)1e6;

	forn(i, 1, n){
		if(u[N - a[i] + 1])
			sum += a[i] - 1;
		else{
			u[N - a[i] + 1] = 1;
			ans.pb(N - a[i] + 1);
		}
	}

	forn(i, 1, N){
		if(u[i] || sum - (N - i) - i + 1 < 0)
			continue;
		sum -= (N - i) - i + 1;
		ans.pb(i);
		ans.pb(N - i + 1);
	}

	//assert(sum == 0);

	cout << (int)ans.size() << "\n";
	for(auto it : ans)
		cout << it << " ";

	return 0;
}


/*
          ______
||  //   | _____|   ||  //
|| //    ||         || //
||//     ||_____    ||//
||\\     | _____|   ||\\
|| \\    ||         || \\   ll Once(ll KEK){
||  \\   ||_____    ||  \\ 		return Forever(KEK);
||   \\  |______|   ||   \\ }

*/
#include<bits/stdc++.h>

using namespace std;
const int N6 = 2e6 + 6, N3 = 1e3 + 6, oo =  1e9 + 9, base = 1e9 + 7;
const long long ool = 1e18 + 9;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;

#define F first
#define S second
#define pb push_back
#define right(x) x << 1 | 1
#define left(x) x << 1
#define	forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)
#define mp make_pair

int n;
ll sum, a[N6];
bool u[N6];
vector <ll> ans;

int main(){
	ios_base :: sync_with_stdio(0);
	cin.tie(0);

	#ifdef KEK
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	#endif

	cin >> n;
	forn(i, 1, n){
		cin >> a[i];
		u[a[i]] = 1;
	}

	int N = (int)1e6;

	forn(i, 1, n){
		if(u[N - a[i] + 1])
			sum += a[i] - 1;
		else{
			u[N - a[i] + 1] = 1;
			ans.pb(N - a[i] + 1);
		}
	}

	forn(i, 1, N){
		if(u[i] || sum - ((N - i) + i - 1) < 0)
			continue;
		sum -= ((N - i) + i - 1);
		ans.pb(i);
		ans.pb(N - i + 1);
	}

	assert(sum == 0);

	cout << (int)ans.size() << "\n";
	for(auto it : ans)
		cout << it << " ";

	return 0;
}