n = int(input())
arr = list(map(int, input().split()))
chet = []
nechet = []
for i in range(n):
    if arr[i] % 2 == 0:
        chet.append(arr[i])
    else:
        nechet.append(arr[i])
chet.sort()
nechet.sort()
if len(chet) == len(nechet) or len(chet) + 1 == len(nechet) or len(nechet) + 1 == len(chet):
    print(0)
elif len(chet) > len(nechet):
    print(sum(chet[0:len(chet)-len(nechet)-1]))
else:
    print(sum(nechet[0:len(nechet)-len(chet)-1]))
