import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Solution {
     public static void main(String args[])
     {
         Scanner sc=new Scanner(System.in);
         int n=sc.nextInt();
         int arr[]=new int[n];
         int even[]=new int[n];
         int odd[]=new int[n];
         int sum=0,l=0,p=0,i;
         for(i=0;i<n;i++)
         {
          arr[i]=sc.nextInt();
             sum+=arr[i];
             if(arr[i]%2==0)
             {
                 even[l]=arr[i];
                 l++;
             }
             else
             { 
                 odd[p]=arr[i];
                 p++;
             }
         }
         int k=Math.min(l,p);
         int j=0,x=0;
         l--;
         p--;
         if(l==-1)
         {
             sum-=odd[p];
             x++;
             System.out.println(sum);
         }
         else if(p==-1)
         {
             x++;
             sum-=even[l];
             System.out.println(sum);
         }
         while(j<k && x==0)
         {
         //System.out.println(l+" "+p+" "+sum);
             sum-=even[l];
             sum-=odd[p];
             l--;
             p--;
             j++;
          }
          if((l==0 ||p==0) && x==0)
              System.out.println("0");
           else if(x==0)
               System.out.println(sum);
     }
}