Polycarp has an array a consisting of n integers.

He wants to play a game with this array. The game consists of several moves. On the first move he chooses any element and deletes it (after the first move the array contains n-1 elements). For each of the next moves he chooses any element with the only restriction: its parity should differ from the parity of the element deleted on the previous move. In other words, he alternates parities (even-odd-even-odd-... or odd-even-odd-even-...) of the removed elements. Polycarp stops if he can't make a move.

Formally: 

  * If it is the first move, he chooses any element and deletes it; 
  * If it is the second or any next move: 
    * if the last deleted element was odd, Polycarp chooses any even element and deletes it; 
    * if the last deleted element was even, Polycarp chooses any odd element and deletes it. 
  * If after some move Polycarp cannot make a move, the game ends. 



Polycarp's goal is to minimize the sum of non-deleted elements of the array after end of the game. If Polycarp can delete the whole array, then the sum of non-deleted elements is zero.

Help Polycarp find this value.

Input

The first line of the input contains one integer n (1 ≤ n ≤ 2000) — the number of elements of a.

The second line of the input contains n integers a_1, a_2, ..., a_n (0 ≤ a_i ≤ 10^6), where a_i is the i-th element of a.

Output

Print one integer — the minimum possible sum of non-deleted elements of the array after end of the game.

Examples

Input


5
1 5 7 8 2


Output


0


Input


6
5 1 2 4 6 3


Output


0


Input


2
1000000 1000000


Output


1000000
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.security.AccessControlException;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.LongStream;
import java.util.stream.Stream;
public class _p001144B {
    static public void main(final String[] args) throws IOException {
        p001144B._main(args);
    }
//begin p001144B.java
static private class p001144B extends Solver{public p001144B(){nameIn="in/900/p001144B.in"
;singleTest=true;}int n;int[]a;@Override protected void solve(){int res=0;Comparator<Integer>
cmp=(x,y)->y-x;PriorityQueue<Integer>even=new PriorityQueue<>(cmp);PriorityQueue<Integer>
odd=new PriorityQueue<>(cmp);for(int v:a){if(v % 2==0){even.add(v);}else{odd.add
(v);}}while(!even.isEmpty()&&!odd.isEmpty()){even.poll();odd.poll();}if(!even.isEmpty
()){even.poll();}else if(!odd.isEmpty()){odd.poll();}if(!even.isEmpty()){res=even
.stream().mapToInt(Integer::intValue).sum();}else if(!odd.isEmpty()){res=odd.stream
().mapToInt(Integer::intValue).sum();}pw.println(res);}@Override public void readInput
()throws IOException{n=sc.nextInt();if(sc.hasNextLine()){sc.nextLine();}a=Arrays
.stream(sc.nextLine().trim().split("\\s+")).mapToInt(Integer::valueOf).toArray()
;}static public void _main(String[]args)throws IOException{new p001144B().run();
}}
//end p001144B.java
//begin net/leksi/contest/Solver.java
static private abstract class Solver{protected String nameIn=null;protected String
nameOut=null;protected boolean singleTest=false;protected boolean preprocessDebug
=false;protected boolean doNotPreprocess=false;protected PrintStream debugPrintStream
=null;protected Scanner sc=null;protected PrintWriter pw=null;final String SPACE
=" ";final String SPACES="\\s+";private void process()throws IOException{if(!singleTest
){int t=lineToIntArray()[0];while(t-->0){readInput();solve();}}else{readInput();
solve();}}abstract protected void readInput()throws IOException;abstract protected
void solve()throws IOException;protected int[]lineToIntArray()throws IOException
{return Arrays.stream(sc.nextLine().trim().split(SPACES)).mapToInt(Integer::valueOf
).toArray();}protected long[]lineToLongArray()throws IOException{return Arrays.stream
(sc.nextLine().trim().split(SPACES)).mapToLong(Long::valueOf).toArray();}protected
String joinToString(final int[]a){return Arrays.stream(a).mapToObj(Integer::toString
).collect(Collectors.joining(SPACE));}protected String joinToString(final long[]
a){return Arrays.stream(a).mapToObj(Long::toString).collect(Collectors.joining(SPACE
));}protected<T>String joinToString(final T[]a){return Arrays.stream(a).map(v->Objects
.toString(v)).collect(Collectors.joining(SPACE));}protected<T>String joinToString
(final T[]a,final Function<T,String>toString){return Arrays.stream(a).map(v->toString
.apply(v)).collect(Collectors.joining(SPACE));}protected<T>String joinToString(final
Collection<T>a){return a.stream().map(v->Objects.toString(v)).collect(Collectors
.joining(SPACE));}protected<T>String joinToString(final Collection<T>a,final Function<T
,String>toString){return a.stream().map(v->toString.apply(v)).collect(Collectors
.joining(SPACE));}protected<T>String joinToString(final Stream<T>a){return a.map
(v->Objects.toString(v)).collect(Collectors.joining(SPACE));}protected<T>String joinToString
(final Stream<T>a,final Function<T,String>toString){return a.map(v->toString.apply
(v)).collect(Collectors.joining(SPACE));}protected<T>String joinToString(final IntStream
a){return a.mapToObj(Integer::toString).collect(Collectors.joining(SPACE));}protected
<T>String joinToString(final LongStream a){return a.mapToObj(Long::toString).collect
(Collectors.joining(SPACE));}protected List<Long>intArrayToLongList(final int[]a
){return Arrays.stream(a).mapToObj(Long::valueOf).collect(Collectors.toList());}
protected List<Integer>toList(final int[]a){return Arrays.stream(a).mapToObj(Integer
::valueOf).collect(Collectors.toList());}protected List<Integer>toList(final IntStream
a){return a.mapToObj(Integer::valueOf).collect(Collectors.toList());}protected List<Long>
toList(final long[]a){return Arrays.stream(a).mapToObj(Long::valueOf).collect(Collectors
.toList());}protected List<Long>toList(final LongStream a){return a.mapToObj(Long
::valueOf).collect(Collectors.toList());}protected<T>List<T>toList(final Stream<T>
a){return a.collect(Collectors.toList());}protected<T>List<T>toList(final T[]a){
return Arrays.stream(a).collect(Collectors.toList());}protected void run()throws
IOException{boolean done=false;try{if(nameIn !=null&&new File(nameIn).exists()){
try(FileInputStream fis=new FileInputStream(nameIn);PrintWriter pw0=select_output
();){done=true;sc=new Scanner(fis);pw=pw0;process();}}}catch(IOException ex){}catch
(AccessControlException ex){}if(!done){try(PrintWriter pw0=select_output();){sc=
new Scanner(System.in);pw=pw0;process();}}}private PrintWriter select_output()throws
FileNotFoundException{if(nameOut !=null){return new PrintWriter(nameOut);}return
new PrintWriter(System.out);}}
//end net/leksi/contest/Solver.java
}
