
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.PriorityQueue;

public class B {
  public static void main(String[] args) throws IOException {
    B a = new B();
    a.solve();
  }

  public void solve() throws IOException {
    Solution solution = new Solution();
    solution.solve();
  }

  public class Solution {

    BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));

    public void solve() throws IOException {
//      int tests = Integer.parseInt(sc.readLine());
//      for (int i = 0; i < tests; i++) {
//        solveNextTest();
//      }
      solveNextTest();
    }

    private void solveNextTest() throws IOException {
      int n = Integer.parseInt(sc.readLine());
      int[] a = new int[n];
      String allValues = sc.readLine();
      String[] possibleValues = allValues.split(" ");
      PriorityQueue<Integer> evenQueue = new PriorityQueue<>((Integer p, Integer q) -> q - p);
      PriorityQueue<Integer> oddQueue = new PriorityQueue<>((Integer p, Integer q) -> q - p);
      for (int k = 0; k < n; k++) {
        a[k] = (Integer.parseInt(possibleValues[k]));
        if ( a[k] % 2 == 1) {
          oddQueue.offer(a[k]);
        } else {
          evenQueue.offer(a[k]);
        }
      }

      boolean moveFrom =  evenQueue.size() > oddQueue.size() ? true : false;
      while (true) {
        if (moveFrom) {
          if (evenQueue.isEmpty()) break;
          evenQueue.poll();
          moveFrom = false;
        } else {
          if (oddQueue.isEmpty()) break;
          oddQueue.poll();
          moveFrom = true;
        }
      }

      int sum = 0;
      while (!evenQueue.isEmpty()) {
        sum += evenQueue.poll();
      }
      while (!oddQueue.isEmpty()) {
        sum += oddQueue.poll();
      }
      System.out.println(sum);
    }

  }

}
