def main():
    n = int(input())
    array = list(map(int,input().split()))
    even = []
    odd = []
    for i in array:
        if i%2 == 0:
            even.append(i)
        else:
            odd.append(i)

    even.sort(reverse = True)
    odd.sort(reverse = True)

    if sum(even) >= sum(odd):
        k = min(len(even),len(odd))
        for i in range(k):
            even.pop()
            odd.pop()
        if even:
            even.pop()
        ans = sum(even)+sum(odd)
    else:
        k = min(len(even),len(odd))
        for i in range(k):
            even.pop()
            odd.pop()
        if odd:
            odd.pop()
        ans = sum(even)+sum(odd)

    print(ans)
    
main()
