n = int(input())
a = list(map(int,input().split()))
odd = []
even = []
for i in a:
    if i % 2:
        odd.append(i)
    else:
        even.append(i)
odd.sort(reverse=True)
even.sort(reverse=True)
o = len(odd)
e = len(even)
if o == e:
    print(0)
elif o < e:
    try:
        print(sum(even[o+1:]))
    except:
        print(0)
elif o > e:
    try:
        print(sum(odd[e+1:]))
    except:
        print(0)
