n = int(input())
arr = list(map(int, input().split()))
odd = [];       even = []
for i in range(n):
    if arr[i] % 2 == 1 :
        odd.append(arr[i])
    else:
        even.append(arr[i])
if abs(len(odd) - len(even)) < 2:
    print(0)
else:
    odd.sort();     even.sort()
    ans = 0
    if(len(odd) > len(even)):
        for i in range(len(odd) - len(even) - 1):
            ans += odd[i]
    else:
        for i in range(len(even) - len(odd) - 1):
            ans += even[i]
    print(ans)
