#include <bits/stdc++.h>
int countSetBits(int n);
using namespace std;
int main() {
  long long n;
  cin >> n;
  int a[n], b[n], c[n];
  int sum = 0, sum1 = 0, m = 0, m1 = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = countSetBits(a[i]);
    if (b[i] % 2 == 0)
      m++;
    else
      m1++;
  }
  sort(a, a + n);
  if (m == m1)
    cout << 0;
  else {
    if (m > m1) {
      int k = m - m1 - 1;
      for (int i = 0; i < n; i++) {
        if (k == 0)
          break;
        else {
          if (b[i] % 2 == 0) {
            sum = sum + a[i];
            k--;
          }
        }
      }
    } else {
      int k = m1 - m - 1;
      for (int i = 0; i < n; i++) {
        if (k == 0)
          break;
        else {
          if (b[i] % 2 != 0) {
            sum = sum + a[i];
            k--;
          }
        }
      }
    }
    cout << sum;
  }
}
int countSetBits(int n) {
  if (n == 0)
    return 0;
  else
    return (n & 1) + countSetBits(n >> 1);
}
