Polycarp has an array a consisting of n integers.

He wants to play a game with this array. The game consists of several moves. On the first move he chooses any element and deletes it (after the first move the array contains n-1 elements). For each of the next moves he chooses any element with the only restriction: its parity should differ from the parity of the element deleted on the previous move. In other words, he alternates parities (even-odd-even-odd-... or odd-even-odd-even-...) of the removed elements. Polycarp stops if he can't make a move.

Formally: 

  * If it is the first move, he chooses any element and deletes it; 
  * If it is the second or any next move: 
    * if the last deleted element was odd, Polycarp chooses any even element and deletes it; 
    * if the last deleted element was even, Polycarp chooses any odd element and deletes it. 
  * If after some move Polycarp cannot make a move, the game ends. 



Polycarp's goal is to minimize the sum of non-deleted elements of the array after end of the game. If Polycarp can delete the whole array, then the sum of non-deleted elements is zero.

Help Polycarp find this value.

Input

The first line of the input contains one integer n (1 ≤ n ≤ 2000) — the number of elements of a.

The second line of the input contains n integers a_1, a_2, ..., a_n (0 ≤ a_i ≤ 10^6), where a_i is the i-th element of a.

Output

Print one integer — the minimum possible sum of non-deleted elements of the array after end of the game.

Examples

Input


5
1 5 7 8 2


Output


0


Input


6
5 1 2 4 6 3


Output


0


Input


2
1000000 1000000


Output


1000000
n = int(input().strip())
a = list(int(i) for i in input().strip().split(' '))
e = []
o = []
for each in a:
    if each % 2 == 0:
        e.append(each)
    else:
        o.append(each)
e = sorted(e)
o = sorted(o)
e1 = [i for i in e]
o1 = [i for i in o]
s1=0
s2=0
if len(e) > 0 and len(o) > 0:
    if e[-1] > o[-1]:
        e.pop()
        p = 1
    else:
        o.pop()
        p = 0
    while(True):
        if p == 1 and len(o) > 0:
            o.pop()
            p = 0
        elif p == 0 and len(e) > 0:
            e.pop()
            p = 1
        else:
            break
    for i in e + o:
        s1 += i
    
    if len(e1) > len(o1):
        e1.pop()
        p = 1
    else:
        o1.pop()
        p = 0
    while(True):
        if p == 1 and len(o1) > 0:
            o1.pop()
            p = 0
        elif p == 0 and len(e1) > 0:
            e1.pop()
            p = 1
        else:
            break
    for i in e1 + o1:
        s2 += i
    print(min(s1,s2))
else:
    s=0
    if len(o) == 0:
        for i in range(len(e)-1):
            s +=e[i]
    else:
        for i in range(len(o)-1):
            s +=o[i]
    print(s)