import math
n = int(input())
list1 = []
list2 = []
for t in map(int,input().split()):
    if(t % 2 == 0):
        list1.append(t)
    else:
        list2.append(t)
list1.sort()
list2.sort()
len1 = len(list1)
len2 = len(list2)
if abs(len1 - len2)<=1:
    print("0")
else:
    add = abs(len1 - len2) - 1
    ans = 0
    if len1 > len2:
        for i in range(0,add):
            ans += list1[i]
    else:
        for i in range(0,add):
            ans += list2[i]
    print(ans)