	import java.util.*;
	import java.lang.*;
	public class Problem_1144_B{
		public static void main(String[] args) {
			Scanner sc=new Scanner(System.in);
			int n=sc.nextInt();
			int[] a=new int[n];
			//int[] odd=new int[n];
			//int[] even=new int[n];
			int e=0,o=0,ans=0,count=0;
			for (int i=0;i<n;i++) {
				a[i]=sc.nextInt();
				if (a[i]%2==0) {
					//even[ecount]=a[i];
					e++;
					//ecount++;
				}
				else{
					//odd[ocount]=a[i];
					o++;
					//ocount++;
				}
			}

			Arrays.sort(a);
						

			if (e==o) {
				System.out.println("0");
			}
			else if (Math.abs(e-o)==1) {
				System.out.println("0");
			}
			else{
				count=0;
				if (e>o) {
					for (int i=0;i<n;i++) {
						if (a[i]%2==0) {
							ans=ans+a[i];
						}
						count++;
						if (count==e-o-1) {
							break;
						}
					}
					System.out.println(ans);
				}
				else{
					for (int i=0;i<n;i++) {
						if (a[i]%2==1) {
							ans=ans+a[i];
						}
						if (count==o-e-2) {
							break;
						}
						count++;
						if (count==e-o-1) {
							break;
						}
					}
					System.out.println(ans);
				}
			}
			
		}
	}