"""
Beautiful is better than ugly.
    Explicit is better than implicit.
Simple is better than complex.
    Complex is better than complicated.
Flat is better than nested.
    Sparse is better than dense.

    * Readability counts *

 // Author : raj1307 - Raj Singh
 // Date   : 3.06.19

"""

from __future__ import division, print_function
import os,sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
else:
    _str = str
    str = lambda x=b"": x if type(x) is bytes else _str(x).encode()

def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().strip().split(" "))
def li(): return list(mi())

def dmain():
    sys.setrecursionlimit(100000000)
    threading.stack_size(40960000)
    thread = threading.Thread(target=main)
    thread.start()

#from collections import deque, Counter, OrderedDict,defaultdict
#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace
#from math import ceil,floor,log,sqrt,factorial,pow,pi
#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
#from decimal import *,threading

abc='abcdefghijklmnopqrstuvwxyz'
abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod,MOD=1000000007,998244353
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]
def getKey(item): return item[0]
def sort2(l):return sorted(l, key=getKey)
def d2(n,m,num):return [[num for x in range(m)] for y in range(n)]
def isPowerOfTwo (x): return (x and (not(x & (x - 1))) )
def decimalToBinary(n): return bin(n).replace("0b","")
def ntl(n):return [int(i) for i in str(n)]

def powerMod(x,y,p):
    res = 1
    x %= p
    while y > 0:
        if y&1:
            res = (res*x)%p
        y = y>>1
        x = (x*x)%p1
    return res

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

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

# For getting input from input.txt file
#sys.stdin = open('input.txt', 'r')

# Printing the Output to output.txt file
#sys.stdout = open('output.txt', 'w')

def main():

    n=ii()
    l=li()

    a=1000000000
    pa=n
    b=1000000000-1
    pb=n

    for i in range(n-1,-1,-1):

        if l[i]%2==0:

            if l[i]>b:
                l[i],l[pb]=l[pb],l[i]
                print(*l)
                exit()

            if l[i]<a:
                a=l[i]
                pa=i
        else:

            if l[i]>a:
               l[i],l[pa]=l[pa],l[i]
               print(*l)
               exit()

            if l[i]<b:
                b=l[i]
                pb=i

    print(*l)

# region fastio

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):
        if self.buffer.tell():
            return self.buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    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)

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", b" "), 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", b"\n"))
    if kwargs.pop("flush", False):
        file.flush()

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

# endregion

if __name__ == "__main__":
    main()
    #dmain()


"""
Beautiful is better than ugly.
    Explicit is better than implicit.
Simple is better than complex.
    Complex is better than complicated.
Flat is better than nested.
    Sparse is better than dense.

    * Readability counts *

 // Author : raj1307 - Raj Singh
 // Date   : 3.06.19

"""

from __future__ import division, print_function
import os,sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
else:
    _str = str
    str = lambda x=b"": x if type(x) is bytes else _str(x).encode()

def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().strip().split(" "))
def li(): return list(mi())

def dmain():
    sys.setrecursionlimit(100000000)
    threading.stack_size(40960000)
    thread = threading.Thread(target=main)
    thread.start()

#from collections import deque, Counter, OrderedDict,defaultdict
#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace
#from math import ceil,floor,log,sqrt,factorial,pow,pi
#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
#from decimal import *,threading

abc='abcdefghijklmnopqrstuvwxyz'
abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod,MOD=1000000007,998244353
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]
def getKey(item): return item[0]
def sort2(l):return sorted(l, key=getKey)
def d2(n,m,num):return [[num for x in range(m)] for y in range(n)]
def isPowerOfTwo (x): return (x and (not(x & (x - 1))) )
def decimalToBinary(n): return bin(n).replace("0b","")
def ntl(n):return [int(i) for i in str(n)]

def powerMod(x,y,p):
    res = 1
    x %= p
    while y > 0:
        if y&1:
            res = (res*x)%p
        y = y>>1
        x = (x*x)%p1
    return res

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

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

# For getting input from input.txt file
#sys.stdin = open('input.txt', 'r')

# Printing the Output to output.txt file
#sys.stdout = open('output.txt', 'w')

def main():

    n=ii()
    l=li()

    a=1000000009
    pa=n
    b=1000000009
    pb=n

    for i in range(n-1,-1,-1):

        if l[i]%2==0:

            if l[i]>b:
                l[i],l[pb]=l[pb],l[i]
                print(*l)
                exit()

            if l[i]<a:
                a=l[i]
                pa=i
        else:

            if l[i]>a:
               l[i],l[pa]=l[pa],l[i]
               print(*l)
               exit()

            if l[i]<b:
                b=l[i]
                pb=i

    print(*l)

# region fastio

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):
        if self.buffer.tell():
            return self.buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    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)

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", b" "), 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", b"\n"))
    if kwargs.pop("flush", False):
        file.flush()

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

# endregion

if __name__ == "__main__":
    main()
    #dmain()


"""
Beautiful is better than ugly.
    Explicit is better than implicit.
Simple is better than complex.
    Complex is better than complicated.
Flat is better than nested.
    Sparse is better than dense.

    * Readability counts *

 // Author : raj1307 - Raj Singh
 // Date   : 3.06.19

"""

from __future__ import division, print_function
import os,sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
else:
    _str = str
    str = lambda x=b"": x if type(x) is bytes else _str(x).encode()

def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().strip().split(" "))
def li(): return list(mi())

def dmain():
    sys.setrecursionlimit(100000000)
    threading.stack_size(40960000)
    thread = threading.Thread(target=main)
    thread.start()

#from collections import deque, Counter, OrderedDict,defaultdict
#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace
#from math import ceil,floor,log,sqrt,factorial,pow,pi
#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
#from decimal import *,threading

abc='abcdefghijklmnopqrstuvwxyz'
abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod,MOD=1000000007,998244353
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]
def getKey(item): return item[0]
def sort2(l):return sorted(l, key=getKey)
def d2(n,m,num):return [[num for x in range(m)] for y in range(n)]
def isPowerOfTwo (x): return (x and (not(x & (x - 1))) )
def decimalToBinary(n): return bin(n).replace("0b","")
def ntl(n):return [int(i) for i in str(n)]

def powerMod(x,y,p):
    res = 1
    x %= p
    while y > 0:
        if y&1:
            res = (res*x)%p
        y = y>>1
        x = (x*x)%p1
    return res

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

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

# For getting input from input.txt file
#sys.stdin = open('input.txt', 'r')

# Printing the Output to output.txt file
#sys.stdout = open('output.txt', 'w')

def main():

    n=ii()
    l=li()
    e=[]
    o=[]
    pe,po=-1,-1
    f=0

    for i in range(n):
        if l[i]%2==0:
            e.append(l[i])
        else:
            o.append(l[i])

    if len(e)==0 or len(o)==0:
        print(*l)
        exit()

    #me=min(e)
    #pe=l.index(me)
    #mo=min(o)
    #po=l.index(mo)
    a=1000000000
    pa=n
    b=1000000000
    pb=n
    e=[]
    o=[]

    for i in range(n-1,-1,-1):
        if l[i]%2==0:
            if l[i]>b:
                l[i],l[pb]=l[pb],l[i]
                print(*l)
                exit()

            if l[i]<pa:
                a=l[i]
                pa=i
        else:
            if l[i]>a:
               l[i],l[pa]=l[pa],l[i]
               print(*l)
               exit()

            if l[i]<pb:
                b=l[i]
                pb=i

    print(*l)

# region fastio

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):
        if self.buffer.tell():
            return self.buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    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)

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", b" "), 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", b"\n"))
    if kwargs.pop("flush", False):
        file.flush()

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

# endregion

if __name__ == "__main__":
    main()
    #dmain()


"""
Beautiful is better than ugly.
    Explicit is better than implicit.
Simple is better than complex.
    Complex is better than complicated.
Flat is better than nested.
    Sparse is better than dense.

    * Readability counts *

 // Author : raj1307 - Raj Singh
 // Date   : 3.06.19

"""

from __future__ import division, print_function
import os,sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
else:
    _str = str
    str = lambda x=b"": x if type(x) is bytes else _str(x).encode()

def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().strip().split(" "))
def li(): return list(mi())

def dmain():
    sys.setrecursionlimit(100000000)
    threading.stack_size(40960000)
    thread = threading.Thread(target=main)
    thread.start()

#from collections import deque, Counter, OrderedDict,defaultdict
#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace
#from math import ceil,floor,log,sqrt,factorial,pow,pi
#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
#from decimal import *,threading

abc='abcdefghijklmnopqrstuvwxyz'
abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod,MOD=1000000007,998244353
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]
def getKey(item): return item[0]
def sort2(l):return sorted(l, key=getKey)
def d2(n,m,num):return [[num for x in range(m)] for y in range(n)]
def isPowerOfTwo (x): return (x and (not(x & (x - 1))) )
def decimalToBinary(n): return bin(n).replace("0b","")
def ntl(n):return [int(i) for i in str(n)]

def powerMod(x,y,p):
    res = 1
    x %= p
    while y > 0:
        if y&1:
            res = (res*x)%p
        y = y>>1
        x = (x*x)%p1
    return res

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

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

# For getting input from input.txt file
#sys.stdin = open('input.txt', 'r')

# Printing the Output to output.txt file
#sys.stdout = open('output.txt', 'w')

def main():

    n=ii()
    l=li()

    a=1000000009
    pa=n
    b=1000000009
    pb=n
    x=0

    for i in range(n-1,-1,-1):
        if l[i]%2==0:
            if l[i]>b:
                l[i],l[pb]=l[pb],l[i]
                #x=[i,pb]

            if l[i]<a:
                a=l[i]
                pa=i
        else:
            if l[i]>a:
               l[i],l[pa]=l[pa],l[i]
               #print(*l)
               #exit()
               x=[i,pa]

            if l[i]<b:
                b=l[i]
                pb=i

    print(*l)

# region fastio

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):
        if self.buffer.tell():
            return self.buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    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)

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", b" "), 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", b"\n"))
    if kwargs.pop("flush", False):
        file.flush()

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

# endregion

if __name__ == "__main__":
    main()
    #dmain()


"""
Beautiful is better than ugly.
    Explicit is better than implicit.
Simple is better than complex.
    Complex is better than complicated.
Flat is better than nested.
    Sparse is better than dense.

    * Readability counts *

 // Author : raj1307 - Raj Singh
 // Date   : 3.06.19

"""

from __future__ import division, print_function
import os,sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
else:
    _str = str
    str = lambda x=b"": x if type(x) is bytes else _str(x).encode()

def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().strip().split(" "))
def li(): return list(mi())

def dmain():
    sys.setrecursionlimit(100000000)
    threading.stack_size(40960000)
    thread = threading.Thread(target=main)
    thread.start()

#from collections import deque, Counter, OrderedDict,defaultdict
#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace
#from math import ceil,floor,log,sqrt,factorial,pow,pi
#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
#from decimal import *,threading

abc='abcdefghijklmnopqrstuvwxyz'
abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod,MOD=1000000007,998244353
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]
def getKey(item): return item[0]
def sort2(l):return sorted(l, key=getKey)
def d2(n,m,num):return [[num for x in range(m)] for y in range(n)]
def isPowerOfTwo (x): return (x and (not(x & (x - 1))) )
def decimalToBinary(n): return bin(n).replace("0b","")
def ntl(n):return [int(i) for i in str(n)]

def powerMod(x,y,p):
    res = 1
    x %= p
    while y > 0:
        if y&1:
            res = (res*x)%p
        y = y>>1
        x = (x*x)%p1
    return res

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

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

# For getting input from input.txt file
#sys.stdin = open('input.txt', 'r')

# Printing the Output to output.txt file
#sys.stdout = open('output.txt', 'w')

def main():

    n=ii()
    l=li()
    a,b=0,0
    for i in range(n):
        if l[i]%2==0:
            a+=1
        else:
            b+=1
    if a!=0 and b!=0:
        l.sort()
    print(*l)

# region fastio

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):
        if self.buffer.tell():
            return self.buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    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)

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", b" "), 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", b"\n"))
    if kwargs.pop("flush", False):
        file.flush()

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

# endregion

if __name__ == "__main__":
    main()
    #dmain()


"""
Beautiful is better than ugly.
    Explicit is better than implicit.
Simple is better than complex.
    Complex is better than complicated.
Flat is better than nested.
    Sparse is better than dense.

    * Readability counts *

 // Author : raj1307 - Raj Singh
 // Date   : 3.06.19

"""

from __future__ import division, print_function
import os,sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
else:
    _str = str
    str = lambda x=b"": x if type(x) is bytes else _str(x).encode()

def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().strip().split(" "))
def li(): return list(mi())

def dmain():
    sys.setrecursionlimit(100000000)
    threading.stack_size(40960000)
    thread = threading.Thread(target=main)
    thread.start()

#from collections import deque, Counter, OrderedDict,defaultdict
#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace
#from math import ceil,floor,log,sqrt,factorial,pow,pi
#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
#from decimal import *,threading

abc='abcdefghijklmnopqrstuvwxyz'
abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod,MOD=1000000007,998244353
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]
def getKey(item): return item[0]
def sort2(l):return sorted(l, key=getKey)
def d2(n,m,num):return [[num for x in range(m)] for y in range(n)]
def isPowerOfTwo (x): return (x and (not(x & (x - 1))) )
def decimalToBinary(n): return bin(n).replace("0b","")
def ntl(n):return [int(i) for i in str(n)]

def powerMod(x,y,p):
    res = 1
    x %= p
    while y > 0:
        if y&1:
            res = (res*x)%p
        y = y>>1
        x = (x*x)%p1
    return res

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

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

# For getting input from input.txt file
#sys.stdin = open('input.txt', 'r')

# Printing the Output to output.txt file
#sys.stdout = open('output.txt', 'w')

def main():

    n=ii()
    l=li()
    e=[]
    o=[]
    pe,po=-1,-1
    f=0

    for i in range(n):
        if l[i]%2==0:
            e.append(l[i])
        else:
            o.append(l[i])

    if len(e)==0 or len(o)==0:
        print(*l)
        exit()

    me=min(e)
    pe=l.index(me)
    mo=min(o)
    po=l.index(mo)
    for i in range(n):
        if l[i]%2==0:
            if l[i]>mo:
                l[i],l[po]=l[po],l[i]
                print(*l)
                exit()
        else:
            if l[i]>me:
                l[i],l[pe]=l[pe],l[i]
                print(*l)
                exit()

    print(*l)

# region fastio

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):
        if self.buffer.tell():
            return self.buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    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)

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", b" "), 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", b"\n"))
    if kwargs.pop("flush", False):
        file.flush()

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

# endregion

if __name__ == "__main__":
    main()
    #dmain()


"""
Beautiful is better than ugly.
    Explicit is better than implicit.
Simple is better than complex.
    Complex is better than complicated.
Flat is better than nested.
    Sparse is better than dense.

    * Readability counts *

 // Author : raj1307 - Raj Singh
 // Date   : 3.06.19

"""

from __future__ import division, print_function
import os,sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
else:
    _str = str
    str = lambda x=b"": x if type(x) is bytes else _str(x).encode()

def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().strip().split(" "))
def li(): return list(mi())

def dmain():
    sys.setrecursionlimit(100000000)
    threading.stack_size(40960000)
    thread = threading.Thread(target=main)
    thread.start()

#from collections import deque, Counter, OrderedDict,defaultdict
#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace
#from math import ceil,floor,log,sqrt,factorial,pow,pi
#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
#from decimal import *,threading

abc='abcdefghijklmnopqrstuvwxyz'
abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod,MOD=1000000007,998244353
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]
def getKey(item): return item[0]
def sort2(l):return sorted(l, key=getKey)
def d2(n,m,num):return [[num for x in range(m)] for y in range(n)]
def isPowerOfTwo (x): return (x and (not(x & (x - 1))) )
def decimalToBinary(n): return bin(n).replace("0b","")
def ntl(n):return [int(i) for i in str(n)]

def powerMod(x,y,p):
    res = 1
    x %= p
    while y > 0:
        if y&1:
            res = (res*x)%p
        y = y>>1
        x = (x*x)%p1
    return res

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

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

# For getting input from input.txt file
#sys.stdin = open('input.txt', 'r')

# Printing the Output to output.txt file
#sys.stdout = open('output.txt', 'w')

def main():

    n=ii()
    l=li()

    a=1000000000
    pa=n
    b=1000000000
    pb=n

    for i in range(n-1,-1,-1):
        if l[i]%2==0:
            if l[i]>b:
                l[i],l[pb]=l[pb],l[i]
                print(*l)
                exit()

            if l[i]<a:
                a=l[i]
                pa=i
        else:
            if l[i]>a:
               l[i],l[pa]=l[pa],l[i]
               print(*l)
               exit()

            if l[i]<b:
                b=l[i]
                pb=i

    print(*l)

# region fastio

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):
        if self.buffer.tell():
            return self.buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    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)

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", b" "), 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", b"\n"))
    if kwargs.pop("flush", False):
        file.flush()

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

# endregion

if __name__ == "__main__":
    main()
    #dmain()


"""
Beautiful is better than ugly.
    Explicit is better than implicit.
Simple is better than complex.
    Complex is better than complicated.
Flat is better than nested.
    Sparse is better than dense.

    * Readability counts *

 // Author : raj1307 - Raj Singh
 // Date   : 3.06.19

"""

from __future__ import division, print_function
import os,sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
else:
    _str = str
    str = lambda x=b"": x if type(x) is bytes else _str(x).encode()

def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().strip().split(" "))
def li(): return list(mi())

def dmain():
    sys.setrecursionlimit(100000000)
    threading.stack_size(40960000)
    thread = threading.Thread(target=main)
    thread.start()

#from collections import deque, Counter, OrderedDict,defaultdict
#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace
#from math import ceil,floor,log,sqrt,factorial,pow,pi
#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
#from decimal import *,threading

abc='abcdefghijklmnopqrstuvwxyz'
abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod,MOD=1000000007,998244353
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]
def getKey(item): return item[0]
def sort2(l):return sorted(l, key=getKey)
def d2(n,m,num):return [[num for x in range(m)] for y in range(n)]
def isPowerOfTwo (x): return (x and (not(x & (x - 1))) )
def decimalToBinary(n): return bin(n).replace("0b","")
def ntl(n):return [int(i) for i in str(n)]

def powerMod(x,y,p):
    res = 1
    x %= p
    while y > 0:
        if y&1:
            res = (res*x)%p
        y = y>>1
        x = (x*x)%p1
    return res

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

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

# For getting input from input.txt file
#sys.stdin = open('input.txt', 'r')

# Printing the Output to output.txt file
#sys.stdout = open('output.txt', 'w')

def main():

    n=ii()
    l=li()

    a=1000000009
    pa=n
    b=1000000009
    pb=n
    x=0
    for i in range(n-1,-1,-1):
        if l[i]%2==0:
            if l[i]>b:
                #l[i],l[pb]=l[pb],l[i]
                x=[i,pb]
            if l[i]<a:
                a=l[i]
                pa=i
        else:
            if l[i]>a:
               #l[i],l[pa]=l[pa],l[i]
               #print(*l)
               #exit()
               x=[i,pa]
            if l[i]<b:
                b=l[i]
                pb=i

    if x==0:
        print(*l)
    else:
        l[x[0]],l[x[1]]=l[x[1]],l[x[0]]
        print(*l)

# region fastio

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):
        if self.buffer.tell():
            return self.buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    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)

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", b" "), 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", b"\n"))
    if kwargs.pop("flush", False):
        file.flush()

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

# endregion

if __name__ == "__main__":
    main()
    #dmain()


from collections import Counter
def main():
    n = int(input())
    A = [int(x) for x in input().split()]
    C = Counter(A)

    odd = [a for a in A if a&1]
    even = [a for a in A if a&1==0]

    odd.sort(reverse = True)
    even.sort(reverse = True)

    B = []
    for a in A:
        small = a if C[a] else 10**9
        if a & 1:
            if even:
                small = min(small, even[-1])
        else:
            if odd:
                small = min(small, odd[-1])
        B.append(small)
        C[small] -= 1
        if odd and small == odd[-1]:
            odd.pop()
        if even and small == even[-1]:
            even.pop()
    print ' '.join(str(b) for b in B)

######## Python 2 and 3 footer by Pajenegod and c1729

# Note because cf runs old PyPy3 version which doesn't have the sped up
# unicode strings, PyPy3 strings will many times be slower than pypy2.
# There is a way to get around this by using binary strings in PyPy3
# but its syntax is different which makes it kind of a mess to use.

# So on cf, use PyPy2 for best string performance.

py2 = round(0.5)
if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import IOBase, BytesIO

BUFSIZE = 8192
class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill(): pass
        return super(FastIO,self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill(); self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

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

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            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')

# Cout implemented in Python
import sys
class ostream:
    def __lshift__(self,a):
        sys.stdout.write(str(a))
        return self
cout = ostream()
endl = '\n'

# Read all remaining integers in stdin, type is given by optional argument, this is fast
def readnumbers(zero = 0):
    conv = ord if py2 else lambda x:x
    A = []; numb = zero; sign = 1; i = 0; s = sys.stdin.buffer.read()
    try:
        while True:
            if s[i] >= b'0' [0]:
                numb = 10 * numb + conv(s[i]) - 48
            elif s[i] == b'-' [0]: sign = -1
            elif s[i] != b'\r' [0]:
                A.append(sign*numb)
                numb = zero; sign = 1
            i += 1
    except:pass
    if s and s[-1] >= b'0' [0]:
        A.append(sign*numb)
    return A

if __name__== "__main__":
  main()


from collections import Counter
def main():
    n = int(input())
    A = [int(x) for x in input().split()]
    C = Counter(A)

    odd = [a for a in A if a&1]
    even = [a for a in A if a&1==0]

    odd.sort(reverse = True)
    even.sort(reverse = True)

    if len(odd)==n or len(even)==n:
        print ' '.join(str(a) for a in A)
    else:
        print ' '.join(str(a) for a in sorted(A))

######## Python 2 and 3 footer by Pajenegod and c1729

# Note because cf runs old PyPy3 version which doesn't have the sped up
# unicode strings, PyPy3 strings will many times be slower than pypy2.
# There is a way to get around this by using binary strings in PyPy3
# but its syntax is different which makes it kind of a mess to use.

# So on cf, use PyPy2 for best string performance.

py2 = round(0.5)
if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import IOBase, BytesIO

BUFSIZE = 8192
class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill(): pass
        return super(FastIO,self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill(); self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

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

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            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')

# Cout implemented in Python
import sys
class ostream:
    def __lshift__(self,a):
        sys.stdout.write(str(a))
        return self
cout = ostream()
endl = '\n'

# Read all remaining integers in stdin, type is given by optional argument, this is fast
def readnumbers(zero = 0):
    conv = ord if py2 else lambda x:x
    A = []; numb = zero; sign = 1; i = 0; s = sys.stdin.buffer.read()
    try:
        while True:
            if s[i] >= b'0' [0]:
                numb = 10 * numb + conv(s[i]) - 48
            elif s[i] == b'-' [0]: sign = -1
            elif s[i] != b'\r' [0]:
                A.append(sign*numb)
                numb = zero; sign = 1
            i += 1
    except:pass
    if s and s[-1] >= b'0' [0]:
        A.append(sign*numb)
    return A

if __name__== "__main__":
  main()


def main():

    n = int(input())
    A = [int(x) for x in input().split()]

    odd = TreeMultiSet([a for a in A if a&1])
    even = TreeMultiSet([a for a in A if a&1==0])

    B = []
    for a in A:
        if a&1:
            smallest = a if a in odd else 10**9
            if even:
                evenmin = even.min()
                if evenmin < smallest:
                    smallest = evenmin
        else:
            smallest = a if a in even else 10**9
            if odd:
                oddmin = odd.min()
                if oddmin<smallest:
                    smallest = oddmin
        B.append(smallest)
        if smallest&1:
            odd.remove(smallest)
        else:
            even.remove(smallest)
    print ' '.join(str(b) for b in B)

######## Python 2 and 3 footer by Pajenegod and c1729

# Note because cf runs old PyPy3 version which doesn't have the sped up
# unicode strings, PyPy3 strings will many times be slower than pypy2.
# There is a way to get around this by using binary strings in PyPy3
# but its syntax is different which makes it kind of a mess to use.

# So on cf, use PyPy2 for best string performance.

py2 = round(0.5)
if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import IOBase, BytesIO

BUFSIZE = 8192
class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill(): pass
        return super(FastIO,self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill(); self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

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

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            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')

# Cout implemented in Python
import sys
class ostream:
    def __lshift__(self,a):
        sys.stdout.write(str(a))
        return self
cout = ostream()
endl = '\n'

# Read all remaining integers in stdin, type is given by optional argument, this is fast
def readnumbers(zero = 0):
    conv = ord if py2 else lambda x:x
    A = []; numb = zero; sign = 1; i = 0; s = sys.stdin.buffer.read()
    try:
        while True:
            if s[i] >= b'0' [0]:
                numb = 10 * numb + conv(s[i]) - 48
            elif s[i] == b'-' [0]: sign = -1
            elif s[i] != b'\r' [0]:
                A.append(sign*numb)
                numb = zero; sign = 1
            i += 1
    except:pass
    if s and s[-1] >= b'0' [0]:
        A.append(sign*numb)
    return A

import random

class TreeSet(object):
    root = 0
    size = 0

    def __init__(self, data=None):
        if data:
            data = iter(sorted(data))
            tmp = [next(data)]
            for d in data:
                if tmp[-1] != d:
                    tmp.append(d)
            data = tmp
            self.root = treap_builder(data)
            self.size = len(data)

    def add(self, key, check_unique=True):
        if not self.root:
            self.size += 1
            self.root = treap_create_node(key)
        elif not (check_unique and key in self):
            self.size += 1
            self.root = treap_insert(self.root, key)

    def remove(self, key):
        self.root = treap_erase(self.root, key)
        self.size -= 1

    def discard(self, key):
        try:
            self.root = treap_erase(self.root, key)
            self.size -= 1
        except KeyError:
            pass

    def ceiling(self, key):
        x = treap_ceiling(self.root, key) if self.root else 0
        return treap_keys[x] if x else None

    def higher(self, key):
        x = treap_higher(self.root, key) if self.root else 0
        return treap_keys[x] if x else None

    def floor(self, key):
        x = treap_floor(self.root, key) if self.root else 0
        return treap_keys[x] if x else None

    def lower(self, key):
        x = treap_lower(self.root, key) if self.root else 0
        return treap_keys[x] if x else None

    def max(self):
        if not self.root:
            raise ValueError('.max() on empty TreeSet/TreeMultiSet')
        return treap_keys[treap_max(self.root)]

    def min(self):
        if not self.root:
            raise ValueError('.min() on empty TreeSet/TreeMultiSet')
        return treap_keys[treap_min(self.root)]

    def __len__(self):
        return self.size

    def __nonzero__(self):
        return bool(self.root)

    __bool__ = __nonzero__

    def __contains__(self, key):
        return treap_keys[treap_floor(self.root, key)] == key if self.root else False

    def __str__(self):
        return 'TreeSet([%s])' % ', '.join(str(key) for key in self)

    __repr__ = __str__

    def __iter__(self):
        if not self.root:
            return iter()
        out = []
        stack = [self.root]
        while stack:
            node = stack.pop()
            if node > 0:
                if right_child[node]:
                    stack.append(right_child[node])
                stack.append(~node)
                if left_child[node]:
                    stack.append(left_child[node])
            else:
                out.append(treap_keys[~node])
        return iter(out)

class TreeMultiSet(TreeSet):
    def __init__(self, data=None):
        if data:
            data = sorted(data)
            self.root = treap_builder(data)
            self.size = len(data)

    def add(self, key):
        return super(TreeMultiSet, self).add(key, False)

    def __str__(self):
        return 'TreeMultiSet([%s])' % ', '.join(str(key) for key in self)

    __repr__ = __str__

# Build a treap in O(n) time using sorted data
def treap_builder(sorted_data):
    def build(begin, end):
        if begin == end:
            return 0
        mid = (begin + end) // 2
        root = treap_create_node(sorted_data[mid])
        left_child[root] = build(begin, mid)
        right_child[root] = build(mid + 1, end)

        # sift down the priorities
        ind = root
        while True:
            lc = left_child[ind]
            rc = right_child[ind]

            if lc and treap_prior[lc] > treap_prior[ind]:
                if rc and treap_prior[rc] > treap_prior[rc]:
                    treap_prior[ind], treap_prior[rc] = treap_prior[rc], treap_prior[ind]
                    ind = rc
                else:
                    treap_prior[ind], treap_prior[lc] = treap_prior[lc], treap_prior[ind]
                    ind = lc
            elif rc and treap_prior[rc] > treap_prior[ind]:
                treap_prior[ind], treap_prior[rc] = treap_prior[rc], treap_prior[ind]
                ind = rc
            else:
                break
        return root

    return build(0, len(sorted_data))

left_child = [0]
right_child = [0]
treap_keys = [0]
treap_prior = [0.0]

def treap_create_node(key):
    treap_keys.append(key)
    treap_prior.append(random.random())
    left_child.append(0)
    right_child.append(0)
    return len(treap_keys) - 1

def treap_split(root, key):
    left_pos = right_pos = 0
    while root:
        if key < treap_keys[root]:
            left_child[right_pos] = right_pos = root
            root = left_child[root]
        else:
            right_child[left_pos] = left_pos = root
            root = right_child[root]
    left, right = right_child[0], left_child[0]
    right_child[left_pos] = left_child[right_pos] = right_child[0] = left_child[0] = 0
    return left, right

def treap_merge(left, right):
    where, pos = left_child, 0
    while left and right:
        if treap_prior[left] > treap_prior[right]:
            where[pos] = pos = left
            where = right_child
            left = right_child[left]
        else:
            where[pos] = pos = right
            where = left_child
            right = left_child[right]
    where[pos] = left or right
    node = left_child[0]
    left_child[0] = 0
    return node

def treap_insert(root, key):
    left, right = treap_split(root, key)
    return treap_merge(treap_merge(left, treap_create_node(key)), right)

def treap_erase(root, key):
    if treap_keys[root] == key:
        return treap_merge(left_child[root], right_child[root])
    node = root
    while root and treap_keys[root] != key:
        parent = root
        root = left_child[root] if key < treap_keys[root] else right_child[root]
    if not root:
        raise KeyError(str(key))
    if root == left_child[parent]:
        left_child[parent] = treap_merge(left_child[root], right_child[root])
    else:
        right_child[parent] = treap_merge(left_child[root], right_child[root])

    return node

def treap_ceiling(root, key):
    while root and treap_keys[root] < key:
        root = right_child[root]
    if not root:
        return 0
    min_node = root
    min_key = treap_keys[root]
    while root:
        if treap_keys[root] < key:
            root = right_child[root]
        else:
            if treap_keys[root] < min_key:
                min_key = treap_keys[root]
                min_node = root
            root = left_child[root]
    return min_node

def treap_higher(root, key):
    while root and treap_keys[root] <= key:
        root = right_child[root]
    if not root:
        return 0
    min_node = root
    min_key = treap_keys[root]
    while root:
        if treap_keys[root] <= key:
            root = right_child[root]
        else:
            if treap_keys[root] < min_key:
                min_key = treap_keys[root]
                min_node = root
            root = left_child[root]
    return min_node

def treap_floor(root, key):
    while root and treap_keys[root] > key:
        root = left_child[root]
    if not root:
        return 0
    max_node = root
    max_key = treap_keys[root]
    while root:
        if treap_keys[root] > key:
            root = left_child[root]
        else:
            if treap_keys[root] > max_key:
                max_key = treap_keys[root]
                max_node = root
            root = right_child[root]
    return max_node

def treap_lower(root, key):
    while root and treap_keys[root] >= key:
        root = left_child[root]
    if not root:
        return 0
    max_node = root
    max_key = treap_keys[root]
    while root:
        if treap_keys[root] >= key:
            root = left_child[root]
        else:
            if treap_keys[root] > max_key:
                max_key = treap_keys[root]
                max_node = root
            root = right_child[root]
    return max_node

def treap_min(root):
    if not root:
        return 0
    while left_child[root]:
        root = left_child[root]
    return root

def treap_max(root):
    if not root:
        return 0
    while right_child[root]:
        root = right_child[root]
    return root

if __name__== "__main__":
  main()


n = input()
a = map(int, raw_input().strip().split())

even = 0
odd = 0
for num in a:
    if num % 2 == 0:
        even = 1
    else:
        odd = 1

if even and odd:
    a.sort()

print ' '.join(map(str, a))


#!/usr/bin/env python
"""<https://github.com/cheran-senthil/PyRival>"""
from __future__ import division, print_function

import collections
import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
else:
    _str = str
    str = lambda x=b"": x if type(x) is bytes else _str(x).encode()

def main():
    n = read_int()
    nums = read_int_array()
    solve(n, nums)

def solve(n, nums):
    odd = any(x % 2 for x in nums)
    even = any(x % 2 == 0 for x in nums)
    if odd and even:
        nums.sort()
    print(' '.join(str(x) for x in nums))

# region fastio

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):
        if self.buffer.tell():
            return self.buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    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)

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", b" "), 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", b"\n"))
    if kwargs.pop("flush", False):
        file.flush()

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

def read():
    return input()

def read_array(sep=None, maxsplit=-1):
    return read().split(sep, maxsplit)

def read_int():
    return int(read())

def read_int_array(sep=None, maxsplit=-1):
    return [int(a) for a in read_array(sep, maxsplit)]

# endregion

if __name__ == "__main__":
    main()


import math
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
odd = 0
for i in a:
  odd += i % 2
if odd == 0 or odd == n:
  [print(i, end=' ') for i in a]
else:
  a = sorted(a)
  [print(i, end=' ') for i in a]


from sys import stdin,stdout
for _ in range(1):#int(stdin.readline())):
    n=int(stdin.readline())
    a=list(map(int,stdin.readline().split()))
    e=o=0
    for v in a:
        if v&1:e=1
        else:o=1
    if e and o:print(*(sorted(a)))
    else:print(*a)


n = int(input())
a = [int(x) for x in input().split()]

for i in range(n):
    for j in range(i, n):
        if a[i] > a[j] and (a[i] + a[j]) % 2 == 1:
            temp = a[i]
            a[i] = a[j]
            a[j] = temp
        if a[i] > a[j] and (a[i] + a[j]) % 2 == 1:
            temp = a[i]
            a[i] = a[j]
            a[j] = temp
print(*a)


n = int(input())
a = [int(x) for x in input().split()]

for i in range(n):
    for k in range(2):
        for j in range(i, n):
            if a[i] > a[j] and (a[i] + a[j]) % 2 == 1:
                temp = a[i]
                a[i] = a[j]
                a[j] = temp
print(*a)


n = int(input())
a = [int(x) for x in input().split()]
flag = 0
for i in range(n):
    if a[i] % 2 == 1:
        flag = 1
if flag == 1:
    a.sort()
print(*a)


n = int(input())
a = [int(x) for x in input().split()]
flag1 = 0
flag2 = 0
for i in range(n):
    if a[i] % 2 == 1:
        flag1 = 1
    if a[i] % 2 == 0:
        flag2 = 1

if flag1 == 1 and flag2 == 1:
    a.sort()
print(*a)


n = int(input())
a = [int(x) for x in input().split()]
flag = 0
for i in range(n):
    if a[i] % 2 == 1:
        flag = 1
if flag == 1:
    for i in range(n):
        for j in range(i, n):
            if a[i] > a[j]:
                temp = a[i]
                a[i] = a[j]
                a[j] = temp
print(*a)


#	!/usr/bin/env python3
#	encoding: UTF-8
#	Modified: <09/Jun/2019 03:37:51 PM>

#	✪ H4WK3yE乡
#	Mohd. Farhan Tahir
#	Indian Institute Of Information Technology (IIIT), Gwalior

from __future__ import division, print_function
from io import IOBase, BytesIO
import sys
import os

py2 = round(0.5)
if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    from __builtin__ import xrange as range

BUFSIZE = 8192

class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill():
            pass
        return super(FastIO, self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill()
            self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

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

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            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)

def get_array(): return list(map(int, sys.stdin.readline().split()))

def get_ints(): return map(int, sys.stdin.readline().split())

def input(): return sys.stdin.readline().rstrip('\r\n')

def main():
    n = int(input())
    arr = get_array()
    even, odd = [], []
    for i in range(n):
        if arr[i] % 2 == 0:
            even.append(i)
        else:
            odd.append(i)
    if len(even) == 0 or len(odd) == 0:
        print(*arr)
        return
    print(*sorted(arr))

if __name__ == "__main__":
    main()


#	!/usr/bin/env python3
#	encoding: UTF-8
#	Modified: <09/Jun/2019 03:29:35 PM>

#	✪ H4WK3yE乡
#	Mohd. Farhan Tahir
#	Indian Institute Of Information Technology (IIIT), Gwalior

from __future__ import division, print_function
import sys

if sys.version_info.major == 2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

def get_array(): return list(map(int, sys.stdin.readline().split()))

def get_ints(): return map(int, sys.stdin.readline().split())

def input(): return sys.stdin.readline().strip()

def main():
    n = int(input())
    arr = get_array()
    even, odd = [], []
    for i in range(n):
        if arr[i] % 2 == 0:
            even.append(i)
        else:
            odd.append(i)
    if len(even) == 0 or len(odd) == 0:
        print(*arr)
        return
    print(*sorted(arr))

if __name__ == "__main__":
    main()


#	!/usr/bin/env python3
#	encoding: UTF-8
#	Modified: <09/Jun/2019 03:38:42 PM>

#	✪ H4WK3yE乡
#	Mohd. Farhan Tahir
#	Indian Institute Of Information Technology (IIIT), Gwalior

from __future__ import division, print_function
from io import IOBase, BytesIO
import sys
import os

py2 = round(0.5)
if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    from __builtin__ import xrange as range

BUFSIZE = 8192

class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill():
            pass
        return super(FastIO, self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill()
            self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

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

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            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)

def get_array(): return list(map(int, sys.stdin.readline().split()))

def get_ints(): return map(int, sys.stdin.readline().split())

def input(): return sys.stdin.readline().rstrip('\r\n')

def main():
    n = int(input())
    arr = get_array()
    even, odd = [], []
    for i in range(n):
        if arr[i] % 2 == 0:
            even.append(i)
        else:
            odd.append(i)
    if len(even) == 0 or len(odd) == 0:
        print(*arr)
        return
    print(*sorted(arr))

if __name__ == "__main__":
    main()


#	!/usr/bin/env python3
#	encoding: UTF-8
#	Modified: <09/Jun/2019 03:39:38 PM>

#	✪ H4WK3yE乡
#	Mohd. Farhan Tahir
#	Indian Institute Of Information Technology (IIIT), Gwalior

from __future__ import division, print_function
from io import IOBase, BytesIO
import sys
import os

py2 = round(0.5)
if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    from __builtin__ import xrange as range

BUFSIZE = 8192

class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill():
            pass
        return super(FastIO, self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill()
            self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

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

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            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)

def get_array(): return list(map(int, sys.stdin.readline().split()))

def get_ints(): return map(int, sys.stdin.readline().split())

def input(): return sys.stdin.readline().rstrip('\r\n')

def main():
    n = int(input())
    arr = get_array()
    even, odd = [], []
    for i in range(n):
        if arr[i] % 2 == 0:
            even.append(i)
        else:
            odd.append(i)
    if len(even) == 0 or len(odd) == 0:
        print(*arr)
        return
    print(*sorted(arr))

if __name__ == "__main__":
    main()


#	!/usr/bin/env python3
#	encoding: UTF-8
#	Modified: <03/Jun/2019 08:20:25 PM>

#	✪ H4WK3yE乡
#	Mohd. Farhan Tahir
#	Indian Institute Of Information Technology (IIIT), Gwalior

import sys

def get_array(): return list(map(int, sys.stdin.readline().split()))

def get_ints(): return map(int, sys.stdin.readline().split())

def input(): return sys.stdin.readline().strip()

def main():
    n = int(input())
    arr = get_array()
    even, odd = [], []
    for i in range(n):
        if arr[i] % 2 == 0:
            even.append(i)
        else:
            odd.append(i)
    if len(even) == 0 or len(odd) == 0:
        print(*arr)
        return
    print(*sorted(arr))

if __name__ == "__main__":
    main()


n = int(input())
if0 = False
if1 = False
a = []
a = list(map(int, input().split()))
for i in a:
  if i % 2 == 0:
    if0 = True
  else:
    if1 = True
  if if0 and if1:
    break
if if0 and if1:
  a.sort()
for i in a:
  print(i, end = ' ')


n=int(input())
a=map(int,input().split())
odd=0
even=0
for i in a:
    if i&1:
        odd += 1
    else:
        even += 1
if odd == n or even == n:
    for i in range(n):
        print(a[i],end=" ")
else:
    a=sorted(a)
    for i in range(n):
        print(a[i],end=" ")


n=int(input())
a=list(map(int,input().split()))
odd=0
even=0
for i in a:
    if i&1:
        odd += 1
    else:
        even += 1
if odd == n or even == n:
    for i in range(len(a)):
        print(a[i],end=" ")
else:
    a=sorted(a)
    for i in range(len(a)):
        print(a[i],end=" ")


import sys
input = sys.stdin.readline

n = int(input())
l = list(map(int, input().split()))
flag = False
for x in l:
	if x & 1:
		flag = True
		break
if flag:
	l = sorted(l)
	print(*l)
else:
	print(*l)


import sys
input = sys.stdin.readline

n = int(input())
l = list(map(int, input().split()))
cnt_odd = 0
cnt_even = 0
for x in l:
	if x & 1:
		cnt_odd += 1
	else:
		cnt_even += 1
if cnt_odd == 0 or cnt_even == 0:
	print(*l)
else:
	l = sorted(l)
	print(*l)


## necessary imports
import sys
input = sys.stdin.readline
# from math import ceil, floor, factorial;

def ceil(x, y):
    return (x + y - 1)//y;

# swap_array function
def swaparr(arr, a,b):
    temp = arr[a];
    arr[a] = arr[b];
    arr[b] = temp

## gcd function
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b, a % b);

## nCr function efficient using Binomial Cofficient
def nCr(n, k):
    if(k > n - k):
        k = n - k
    res = 1
    for i in range(k):
        res = res * (n - i)
        res = res / (i + 1)
    return int(res)

## upper bound function code -- such that e in a[:i] e < x;
def upper_bound(a, x, lo=0, hi = None):
    if hi == None:
        hi = len(a);
    while lo < hi:
        mid = (lo+hi)//2
        if a[mid] < x:
            lo = mid+1
        else:
            hi = mid
    return lo

## prime factorization
def primefs(n):
    ## if n == 1    ## calculating primes
    primes = {}
    while(n%2 == 0 and n > 0):
        primes[2] = primes.get(2, 0) + 1
        n = n//2
    for i in range(3, int(n**0.5)+2, 2):
        while(n%i == 0 and n > 0):
            primes[i] = primes.get(i, 0) + 1
            n = n//i
    if n > 2:
        primes[n] = primes.get(n, 0) + 1
    ## prime factoriazation of n is stored in dictionary
    ## primes and can be accesed. O(sqrt n)
    return primes

## MODULAR EXPONENTIATION FUNCTION
def power(x, y, p):
    res = 1
    x = x % p
    if (x == 0) :
        return 0
    while (y > 0) :
        if ((y & 1) == 1) :
            res = (res * x) % p
        y = y >> 1
        x = (x * x) % p
    return res

## DISJOINT SET UNINON FUNCTIONS
def swap(a,b):
    temp = a
    a = b
    b = temp
    return a,b

# find function with path compression included (recursive)
# def find(x, link):
#     if link[x] == x:
#         return x
#     link[x] = find(link[x], link);
#     return link[x];

# find function with path compression (ITERATIVE)
def find(x, link):
    p = x;
    while( p != link[p]):
        p = link[p];

    while( x != p):
        nex = link[x];
        link[x] = p;
        x = nex;
    return p;

# the union function which makes union(x,y)
# of two nodes x and y
def union(x, y, link, size):
    x = find(x, link)
    y = find(y, link)
    if size[x] < size[y]:
        x,y = swap(x,y)
    if x != y:
        size[x] += size[y]
        link[y] = x

## returns an array of boolean if primes or not USING SIEVE OF ERATOSTHANES
def sieve(n):
    prime = [True for i in range(n+1)]
    p = 2
    while (p * p <= n):
        if (prime[p] == True):
            for i in range(p * p, n+1, p):
                prime[i] = False
        p += 1
    return prime

#### PRIME FACTORIZATION IN O(log n) using Sieve ####
MAXN = int(1e7 + 5)
def spf_sieve():
    spf[1] = 1;
    for i in range(2, MAXN):
        spf[i] = i;
    for i in range(4, MAXN, 2):
        spf[i] = 2;
    for i in range(3, ceil(MAXN ** 0.5), 2):
        if spf[i] == i:
            for j in range(i*i, MAXN, i):
                if spf[j] == j:
                    spf[j] = i;
    ## function for storing smallest prime factors (spf) in the array

################## un-comment below 2 lines when using factorization #################
# spf = [0 for i in range(MAXN)]
# spf_sieve()
def factoriazation(x):
    ret = {};
    while x != 1:
        ret[spf[x]] = ret.get(spf[x], 0) + 1;
        x = x//spf[x]
    return ret
    ## this function is useful for multiple queries only, o/w use
    ## primefs function above. complexity O(log n)

## taking integer array input
def int_array():
    return list(map(int, input().strip().split()))
## taking string array input
def str_array():
    return input().strip().split();

#defining a couple constants
MOD = int(1e9)+7;
CMOD = 998244353;
INF = float('inf'); NINF = -float('inf');

################### ---------------- TEMPLATE ENDS HERE ---------------- ###################

n = int(input()); a = int_array();
odd = even = 0;
for i in a:
    if i & 1:
        odd += 1;
    else:
        even += 1;
if odd and even:
    print(*sorted(a));
else:
    print(*a);


## necessary imports
import sys
input = sys.stdin.readline
from math import log2, log, ceil

# swap_array function
def swaparr(arr, a,b):
    temp = arr[a];
    arr[a] = arr[b];
    arr[b] = temp

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

## nCr function efficient using Binomial Cofficient
def nCr(n, k):
    if(k > n - k):
        k = n - k
    res = 1
    for i in range(k):
        res = res * (n - i)
        res = res / (i + 1)
    return res

## upper bound function code -- such that e in a[:i] e < x;
def upper_bound(a, x, lo=0):
    hi = len(a)
    while lo < hi:
        mid = (lo+hi)//2
        if a[mid] < x:
            lo = mid+1
        else:
            hi = mid
    return lo

## prime factorization
def primefs(n):
    ## if n == 1    ## calculating primes
    primes = {}
    while(n%2 == 0):
        primes[2] = primes.get(2, 0) + 1
        n = n//2
    for i in range(3, int(n**0.5)+2, 2):
        while(n%i == 0):
            primes[i] = primes.get(i, 0) + 1
            n = n//i
    if n > 2:
        primes[n] = primes.get(n, 0) + 1
    ## prime factoriazation of n is stored in dictionary
    ## primes and can be accesed. O(sqrt n)
    return primes

## MODULAR EXPONENTIATION FUNCTION
def power(x, y, p):
    res = 1
    x = x % p
    if (x == 0) :
        return 0
    while (y > 0) :
        if ((y & 1) == 1) :
            res = (res * x) % p
        y = y >> 1
        x = (x * x) % p
    return res

## DISJOINT SET UNINON FUNCTIONS
def swap(a,b):
    temp = a
    a = b
    b = temp
    return a,b

# find function
def find(x, link):
    while(x != link[x]):
        x = link[x]
    return x

# the union function which makes union(x,y)
# of two nodes x and y
def union(x, y, link, size):
    x = find(x, link)
    y = find(y, link)
    if size[x] < size[y]:
        x,y = swap(x,y)
    if x != y:
        size[x] += size[y]
        link[y] = x

## returns an array of boolean if primes or not USING SIEVE OF ERATOSTHANES
def sieve(n):
    prime = [True for i in range(n+1)]
    p = 2
    while (p * p <= n):
        if (prime[p] == True):
            for i in range(p * p, n+1, p):
                prime[i] = False
        p += 1
    return prime

#### PRIME FACTORIZATION IN O(log n) using Sieve ####
MAXN = int(1e6 + 5)
def spf_sieve():
    spf[1] = 1;
    for i in range(2, MAXN):
        spf[i] = i;
    for i in range(4, MAXN, 2):
        spf[i] = 2;
    for i in range(3, ceil(MAXN ** 0.5), 2):
        if spf[i] == i:
            for j in range(i*i, MAXN, i):
                if spf[j] == j:
                    spf[j] = i;
    ## function for storing smallest prime factors (spf) in the array

################## un-comment below 2 lines when using factorization #################
# spf = [0 for i in range(MAXN)]
# spf_sieve()
def factoriazation(x):
    ret = {};
    while x != 1:
        ret[spf[x]] = ret.get(spf[x], 0) + 1;
        x = x//spf[x]
    return ret
    ## this function is useful for multiple queries only, o/w use
    ## primefs function above. complexity O(log n)

## taking integer array input
def int_array():
    return list(map(int, input().strip().split()))
## taking string array input
def str_array():
    return input().strip().split();

#defining a couple constants
MOD = int(1e9)+7;
CMOD = 998244353;
INF = float('inf'); NINF = -float('inf');

################### ---------------- TEMPLATE ENDS HERE ---------------- ###################

n = int(input()); a = int_array(); count = 0;
for i in a:
    if i % 2 != 0:
        count += 1;
if count != 0 and count != n:
    print(*sorted(a))
else:
    print(*a)


n = int(input())
a = [int(i) for i in input().split()]
first = []
second = []
for i in range(n):
    if a[i] % 2 == 1:
        first.append(a[i])
    else:
        second.append(a[i])
first.sort()
second.sort()
for i in range(n):
    if a[i] % 2 == 0 and len(first) != 0 and a[i] > first[0]:
        index = a.index(first[0])
        x = first.pop(0)
        if index > i:
            a[index] = a[i]
            a[i] = x
    elif a[i] % 2 == 1 and len(second) != 0 and a[i] > second[0]:
        index = a.index(second[0])
        x = second.pop(0)
        if index > i:
            a[index] = a[i]
            a[i] = x
    else:
        continue
print(*a)


n = int(input())
a = [int(i) for i in input().split()]
k1 = 0
k2 = 0
i = 0
while k1 == 0 or k2 == 0 and i<n:
    if a[i] % 2 == 1:
        k1 += 1
    else:
        k2+= 1
    i+= 1
if k1*k2 != 0:
    a.sort()
    print(*a)
else:
    print(*a)


n = int(input())
a = [int(i) for i in input().split()]
k1 = 0
k2 = 0
i = 0
while k1 == 0 or k2 == 0 :
    if i >= n:
        break
    if a[i] % 2 == 1:
        k1 += 1
    else:
        k2 += 1
    i+= 1
if k1*k2 != 0:
    a.sort()
    print(*a)
else:
    print(*a)


n = int(input())
a = [int(i) for i in input().split()]
first = []
second = []
for i in range(n):
    if a[i] % 2 == 1:
        first.append(a[i])
    else:
        second.append(a[i])
new = []
for i in range(n):
    if len(second) != 0 and len(first) != 0:
        if first[0] < second[0]:
            x = first.pop(0)
        else:
            x = second.pop(0)
        new.append(x)
    else:
        if len(second) == 0:
            x = first.pop(0)
        else:
            x = second.pop(0)
        new.append(x)
print(*new)


n = int(input())

l = list(map(int,input().split()))

l1 = []
l2 = []

for i in range(n):
    if l[i]%2 == 0:
        l1.append(l[i])

    else:
        l2.append(l[i])

if len(l1) == 0 or len(l2) == 0:
    print(*l)
else:
    l.sort()
    print(*l)


l = list(map(int,input().split()))

l1 = []
l2 = []

for i in range(n):
    if l[i]%2 == 0:
        l1.append(l[i])

    else:
        l2.append(l[i])

if len(l1) == 0 or len(l2) == 0:
    print(*l)
else:
    l.sort()
    print(*l)


def f(m, n):
	o, e = [], []
	for i in range(n):
		e.append(i) if a[i] % 2 == 0 else o.append(i)
	return o, e
def s(m, a, b):
	for i in range(min(len(a), len(b))):
		if m[b[i]] < m[a[i]]:
			m[b[i]], m[a[i]] = m[a[i]], m[b[i]]
	return m
n = int(input())
a = list(map(int, input().split()))
o, e = f(a, n)
a = s(a, o, e)
o, e = f(a, n)
print(*[x for x in s(a, e, o)])


n = int(input())
a = list(map(int, input().split()))
if len([x for x in a if x % 2 ==0]) in (0, n):
	print(a)
else:
	print(*[x for x in sorted(a)])


n = int(input())
a = list(map(int, input().split()))
if len([x for x in a if x % 2 ==0]) in (0, n):
	print(*[x for x in a])
else:
	print(*[x for x in sorted(a)])


def f(m, n):
	o, e = [], []
	for i in range(n):
		e.append(i) if m[i] % 2 == 0 else o.append(i)
	return o, e
def s(m, a, b):
	for i in range(min(len(a), len(b))):
		if m[b[i]] < m[a[i]]:
			m[b[i]], m[a[i]] = m[a[i]], m[b[i]]
	return m
n = int(input())
a = list(map(int, input().split()))
o, e = f(sorted(a), n)
print(*[x for x in s(a, o, e)])


n = int(input())
A = [int(i) for i in input().split()]

new = [A[i]&1 for i in range(n)]

if sum(new)==0 or sum(new)==n:
    print(*A)
else:
    print(*sorted(A))


n=int(input())
l=list(map(int,input().split()))
odd=[]
even=[]
for i in l:
    if i%2:
        odd.append(i)
    else:
        even.append(i)
odd.sort()
even.sort()
i,j,ol,el=0,0,len(odd),len(even)
ans=[]
for e in l:
    if e%2:
        if(j<el):
            ans.append(even[j])
            j+=1
        else:
            ans.append(e)
    else:
        if(i<ol):
            ans.append(odd[j])
            i+=1
        else:
            ans.append(e)
for i in ans:
    print(i,end=" ")


n=int(input())
l=list(map(int,input().split()))
even,odd=0,0
for i in l:
    if i%2:
        even+=1
    else:
        odd+=1
if(even==0 or odd==0):
    for i in l:
        print(i,end=" ")
else:
    l.sort()
    for i in l:
        print(i,end=" ")


n=int(input())
nlist =list(map(int,input().split()))
ans=True
check=nlist[0]%2
for i in range(1,n):
	if (nlist[i]%2!=check):
		ans=False
		break
if (ans):
	for i in range(n):
		print(nlist[i],end=" ")
else:
	nlist.sort()
	for i in range(n):
		print(nlist[i],end=" ")


def mergeSort(nlist):

    if len(nlist)>1:
        mid = len(nlist)//2
        lefthalf = nlist[:mid]
        righthalf = nlist[mid:]

        mergeSort(lefthalf)
        mergeSort(righthalf)
        i=j=k=0
        while i < len(lefthalf) and j < len(righthalf):
            if (lefthalf[i] >= righthalf[j] and ((lefthalf[i]+righthalf[j])%2==1)):
                nlist[k]=righthalf[j]
                j=j+1
            else:

                nlist[k]=lefthalf[i]
                i=i+1
            k=k+1

        while i < len(lefthalf):
            nlist[k]=lefthalf[i]
            i=i+1
            k=k+1

        while j < len(righthalf):
            nlist[k]=righthalf[j]
            j=j+1
            k=k+1

n=int(input())
nlist =list(map(int,input().split()))
mergeSort(nlist)
for i in range(n):
	print(nlist[i],end=" ")


n = int(input())
a = list(map(int,input().split()))
odd = [x for x in a if x%2 ]
even = [x for x in a if not x%2 ]
len_o = len(odd)
len_e = len(even)
if len_o==0 or len_e==0:
    print(*a)
else:
    print(*sorted(a))


n = int(input())
a = list(map(int,input().split()))
odd = [x for x in a if x%2 ]
even = [x for x in a if not x%2 ]
len_o = len(odd)
len_e = len(even)
if len_o==0 and len_e==0:
    print(*a)
else:
    print(*sorted(a))


n = int(input())
a = list(map(int,input().split()))
odd = [x for x in a if x%2 ]
even = [x for x in a if not x%2 ]
len_o = len(odd)
len_e = len(even)
io = ie = i = 0
res = [None]*n
while io<len_o and ie<len_e:
    if odd[io]<even[ie]:
        res[i]=odd[io]
        io+=1
    else:
        res[i]=even[ie]
        ie+=1
    i+=1
if io==len_o and ie==len_e:
    print(res)
elif io<len_o:
    res[i:] = odd[io:]
else:
    res[i:] = even[ie:]
print(*res)


#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase
#from bisect import bisect_left as bl                #c++ lowerbound bl(array,element)
#from bisect import bisect_right as br               #c++ upperbound br(array,element)

def main():
    n=int(input(()))
    a=list(map(int,input().split(" ")))
    chk=0
    chkk=0
    for x in a:
        if x%2==0:
            chk=1
        if x%2!=0:
            chkk=1
    if chk==1 and chkk==1:
        a.sort()
        print(a)
    else:
        print(a)

#-----------------------------BOSS-------------------------------------!
# region fastio

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")

# endregion

if __name__ == "__main__":
    main()


#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase
#from bisect import bisect_left as bl                #c++ lowerbound bl(array,element)
#from bisect import bisect_right as br               #c++ upperbound br(array,element)

def main():
    n=int(input())
    a=list(map(int,input().split(" ")))
    chk=0
    chkk=0
    for x in a:
        if x%2==0:
            chk=1
        if x%2!=0:
            chkk=1
    if chk==1 and chkk==1:
        a.sort()
        print(*a)
    else:
        print(*a)

#-----------------------------BOSS-------------------------------------!
# region fastio

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")

# endregion

if __name__ == "__main__":
    main()


n = int(input())
a = list(map(int, input().split()))
b = set(i % 2 for i in a)
if len(b) != 1:
    a = sorted(a)
for i in a:
    print(i, end = ' ')


n = int(input())
a = list(map(int, input().split()))
b = set(i % 2 for i in a)
if set(b) != 1:
    a = sorted(a)
for i in a:
    print(i, end = ' ')


n = int(input().strip())
arr = list(map(int, input().strip().split()))
odds, evens = 0, 0
for ele in arr:
	if ele%2:
		odds += 1
	else:
		evens += 1
if odds == 0 or evens == 0:
	print(*arr)
else:
	arr.sort()
	print(*arr)


def medianOf3(a, left, right):
	"""
	Chooses the median element out of the left, right and middle elements of the given subarray
	Returns the value of the pivot element that ought to be chosen
	"""
	return sorted([a[left], a[right], a[(left+right)//2]])[1]

def partition(a, left, right):
	"""
	Swaps elemnts untill the pivot is in the ideal place.
	Takes O(n) time.
	i represents index at which partition occured.
	a[i] is the leftmost element of the subarray containing elements > than pivot
	Input: array to be sorted, left index of subarray, right index of subarray
	Output: Index of pivot
	"""

	# Choosing pivot by method of 'median-of-three'
	pivot = medianOf3(a, left, right)
	# Swapping the chosen pivot to the left index
	a[a.index(pivot)], a[left] = a[left], a[a.index(pivot)]

	# Partition and swaps
	i = left + 1
	for j in range(left+1, right+1):    # from left+1 of array to right of array
		if a[j] < pivot:
			if (a[i]+a[j])%2:
				a[j], a[i] = a[i], a[j]     # swapping smaller element with the leftmost element of larger array
			i += 1                      # incrementing partition index

	# swapping pivot with rightmost element of the smaller subarray
	a[left], a[i-1] = a[i-1], a[left]

	return i-1                          # index of pivot

def quicksort(a, left=0, right=None):
	"""
	Recursively divides and sorts subarrays
	Inplace sorting so returns nothing, just sorts the given array inplace
	"""
	if right == None:
		right = len(a)-1                 # if we are in the first call of recursion

	# Base case when pivot is ideally placed
	if left >= right:
		return                           # Backtracking

	# else recursively partition left and right subarrays of the pivot
	pivInd = partition(a, left, right)
	quicksort(a, left, pivInd-1)         # left half
	quicksort(a, pivInd+1, right)        # right half

n = int(input().strip())
arr = list(map(int, input().strip().split()))

quicksort(arr)
print(*arr)


#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <vector>
using namespace std;
int main() {
    int n;
    cin>>n;
    int ar[10001];
    for (int i=0; i<n; i++)
    {
    cin>>ar[i];
    }
    sort(ar,ar+n);
    int dp[1001];
    int was = 1;
    dp[0] = 0;
    for (int i=1; i<=n; i++)
    {
      dp[i] = dp[i-1]+abs(i-ar[i-1]);
      was++;
    }
    cout << dp[n];
    return 0;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <vector>
using namespace std;
int main() {
    int n;
    cin>>n;
    int ar[100001];
    for (int i=0; i<n; i++)
    {
    cin>>ar[i];
    }
    sort(ar,ar+n);
    int dp[100001];
    int was = 1;
    dp[0] = 0;
    for (int i=1; i<=n; i++)
    {
      dp[i] = dp[i-1]+abs(i-ar[i-1]);
      was++;
    }
    cout << dp[n];
    return 0;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <vector>
using namespace std;
int main() {
    int n;
    cin>>n;
    long long ar[300001];
    for (int i=0; i<n; i++)
    {
    cin>>ar[i];
    }
    sort(ar,ar+n);
    long long dp[300001];
    int was = 1;
    dp[0] = 0;
    for (int i=1; i<=n; i++)
    {
      dp[i] = dp[i-1]+abs(i-ar[i-1]);
      was++;
    }
    cout << dp[n];
    return 0;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <vector>
using namespace std;
int main() {
    int n;
    cin>>n;
    long long ar[10001];
    for (int i=0; i<n; i++)
    {
    cin>>ar[i];
    }
    sort(ar,ar+n);
    long long dp[4001];
    int was = 1;
    dp[0] = 0;
    for (int i=1; i<=n; i++)
    {
      dp[i] = dp[i-1]+abs(i-ar[i-1]);
      was++;
    }
    cout << dp[n];
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

const
int nmax = 100000;

typedef int arr[nmax];

int main()
{
	arr a;
	int n;
	int result = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	sort(a,a+n);
	for (int i = 0; i < n; i++)
	{
		result = result + a[i] - (i + 1);
	}
	cout << abs(result);
	    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

const
int nmax = 100000;

typedef int arr[nmax];

int main()
{
	arr a;
	int n;
	int result = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	sort(a,a+n);
	for (int i = 0; i < n; i++)
	{
		result = abs(result + a[i] - (i + 1));
	}
	cout << result;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

const
int nmax = 100000;

typedef int arr[nmax];

int main()
{
	arr a;
	int n;
	int result = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	sort(a,a+n);
	for (int i = 0; i < n; i++)
	{
		result = result + a[i] - (i + 1);
	}
	result = abs(result);
	cout << result;
}


#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

const
int nmax = 300000;

typedef int arr[nmax];

int main()
{
	arr a;
	int n;
	long long result = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	sort(a,a+n);
	for (int i = 0; i < n; i++)
	{
		if (a[i] > i + 1) result += abs(a[i] - i - 1);
		else result += abs(i + 1 - a[i]);
	}
	cout << result;
}


#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

const
int nmax = 100000;

typedef int arr[nmax];

int main()
{
	arr a;
	int n;
	int result = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	sort(a,a+n);
	for (int i = 0; i < n; i++)
	{
		result = result + a[i] - (i + 1);
	}
	result = abs(result);
	cout << result;
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

const
int nmax = 100000;

typedef int arr[nmax];

int main()
{
	arr a;
	int n;
	int result = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	sort(a,a+n);
	for (int i = 0; i < n; i++)
	{
		result = abs(result + abs(a[i]) - (i + 1));
	}
	cout << result;
}


#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

const
int nmax = 100000;

typedef int arr[nmax];

int main()
{
	arr a;
	int n;
	int result = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	sort(a,a+n);
	for (int i = 0; i < n; i++)
	{
		if (a[i] > i + 1) result += abs(a[i] - i - 1);
		else result += abs(i + 1 - a[i]);
	}
	cout << result;
}


#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

const
int nmax = 100000;

typedef int arr[nmax];

int main()
{
	arr a;
	int n;
	long long result = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	sort(a,a+n);
	for (int i = 0; i < n; i++)
	{
		if (a[i] > i + 1) result += abs(a[i] - i - 1);
		else result += abs(i + 1 - a[i]);
	}
	cout << result;
}


#include <stdio.h>
#include <algorithm>
#include <iostream>
using namespace std;

int main(){
long long n;
long long arr[500000];
scanf("%I64d", &n);
for(int i=0; i<n; ++i) scanf("%I64d", &arr[i]);
sort(arr, arr+n);
int res=0;
for(int i=1; i<=n; ++i) res+=abs(arr[i-1]-i);
cout << res;
return 0


#include <stdio.h>
#include <algorithm>
#include <iostream>
using namespace std;

int main(){
long long n;
long long arr[500000];
scanf("%I64d", &n);
for(int i=0; i<n; ++i) scanf("%I64d", &arr[i]);
sort(arr, arr+n);
long long res=0;
for(int i=1; i<=n; ++i) res+=abs(arr[i-1]-i);
cout << res;
return 0;
}


#include <stdio.h>
#include <algorithm>
#include <iostream>
using namespace std;

int main(){
int n;
int arr[500000];
scanf("%d", &n);
for(int i=0; i<n; ++i) scanf("%d", &arr[i]);
sort(arr, arr+n);
int res=0;
for(int i=0; i<n; ++i) res+=abs(arr[i]-i-1);
cout << res;
return 0;
}


#include <stdio.h>
#include <algorithm>
#include <iostream>
using namespace std;

int main(){
long long n;
long long arr[500000];
scanf("%I64d", &n);
for(int i=0; i<n; ++i) scanf("%I64d", &arr[i]);
sort(arr, arr+n);
int res=0;
for(int i=1; i<=n; ++i) res+=abs(arr[i-1]-i);
cout << res;
return 0;
}


#include <stdio.h>
#include <algorithm>
#include <iostream>
using namespace std;

int main(){
long long n;
long long arr[500000];
scanf("%I64d", &n);
for(int i=0; i<n; ++i) scanf("%I64d", &arr[i]);
sort(arr, arr+n);
int res=0;
for(int i=1; i<n; ++i) res+=abs(arr[i-1]-i);
cout << res;
return 0;
}


#include <stdio.h>
#include <algorithm>
#include <iostream>
using namespace std;

int main(){
int n;
int arr[500000];
scanf("%d", &n);
for(int i=0; i<n; ++i) scanf("%d", &arr[i]);
sort(arr, arr+n);
int res=0;
for(int i=0; i<n; ++i) res+=abs(arr[i]-i);
cout << res;
return 0;
}


#include<iostream>
#include<string>
#include<cmath>
using namespace std;

long long  p[300005];
int cmp(const void *a, const void *b)
{
    if(*(long long*)a > *(long long*)b)
        return 1;
    else
        return -1;
}
int main()
{
    int n;
    long long i,j;
    long long sum;

    scanf("%d", &n);
    for(i=1; i<=n; ++i)
        scanf("%I64d", &p[i]);
    qsort(p+1, n, sizeof(long long), cmp);
    sum = 0;
    for(i=1; i<=n; ++i)
    {
        sum += (p[i]>i ? p[i]-i : i-p[i]);
    }
    printf("%I64d", sum);
    return 0;
}


#include<iostream>
#include<string>
#include<cmath>
using namespace std;

long long  p[300005];
int cmp(const void *a, const void *b)
{
    if( *(long long  *)a > *(long long *)b)
        return 1;
    else
       return -1;
}
int main()
{
    int n;
    int i,j;
    long long sum;

    scanf("%d", &n);
    for(i=1; i<=n; ++i)
        scanf("%I64d", &p[i]);
    qsort(p+1, n, sizeof(long long), cmp);
    sum = 0;
    for(i=1; i<=n; ++i)
    {
        sum += abs(p[i]-i);
    }
    printf("%I64d", sum);
    return 0;
}


#include<iostream>
#include<string>
#include<cmath>
using namespace std;

int  p[310005];
int cmp(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
int main()
{
    int n;
    int i,j;
    long long sum;

    scanf("%d", &n);
    for(i=1; i<=n; ++i)
        scanf("%d", &p[i]);
    qsort(p+1, n, sizeof(int), cmp);
    sum = 0;
    for(i=1; i<=n; ++i)
    {
        sum += (p[i]>i ? p[i]-i : i-p[i]);
    }
    printf("%I64d", sum);
    return 0;
}