#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  clock_t clk = clock();
  cerr << "I will return...\n";
  int n;
  cin >> n;
  long long int a[n];
  long long int sum = 0;
  int count_odd = 0, count_even = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] % 2 == 0)
      count_even++;
    else
      count_odd++;
  }
  if (n % 2 == 0) {
    if (count_odd - count_even == 0)
      cout << 0;
    else {
      sort(a, a + n);
      for (int i = 0; i < abs(count_even - count_odd); i++) {
        sum += a[i];
      }
      cout << sum;
    }
  } else {
    if (abs(count_odd - count_even) == 1)
      cout << 0;
    else {
      sort(a, a + n);
      for (int i = 0; i < abs(count_even - count_odd); i++) {
        sum += a[i];
      }
      cout << sum;
    }
  }
  cerr << "...no matter what.\n";
  cerr << "Time (in ms): " << double(clock() - clk) * 1000.0 / CLOCKS_PER_SEC
       << '\n';
}
