if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))
    total_sum = sum(a)
    odd = [x for x in a if x % 2 == 1]
    even = [x for x in a if x % 2 == 0]
    odd.sort(reverse=True)
    even.sort(reverse=True)
    len1 = len(odd)
    len2 = len(even)
    m = min(len1, len2)
    sum1 = sum(odd[:m])
    sum1 += sum(even[:m])
    if len1 > m:
        sum1 += odd[m]
    if len2 > m:
        sum1 += even[m]
    print(total_sum - sum1)
