import math
n = int(input())
ce = 0
co = 0
arr2 = []
arr3 = []
arr = list(map(int, input().split()))
arr.sort(reverse = True)
for k in arr:

    if k % 2 == 0:
        ce += 1
        arr2.append(k)
    else:
        co += 1
        arr3.append(k)
po = min(ce, co) + 1
if ce == co or ce - 1 == co or co - 1 == ce:
    print(0)
elif ce > co:
    ans = sum(arr2) - sum(arr2[0:po])
    print(ans)
else:
    ans = sum(arr3) - sum(arr3[0:po])
    print(ans)