
def solve(isOdd, odd, even):
    if isOdd  and len(odd) == 0:
        return sum(even) + sum(odd)
    if not isOdd and len(even) == 0:
        return sum(even) + sum(odd)
    if isOdd:
        return solve(False, odd[1:], even)
    else:
        return solve(True, odd, even[1:])
    


n = int(raw_input())
arr = map(int,raw_input().split())
arr.sort(reverse=True)
odd = []
even = []
for elm in arr:
    if elm%2 == 0: even.append(elm)
    else: odd.append(elm)
print min(solve(True, odd[:], even[:]), solve(False, odd[:], even[:]))
