#include <bits/stdc++.h>
using namespace std;
int n, tot;
int h[1000];
int w[1000];
int f(int x) {
  vector<int> v;
  int res = tot, s = 0;
  for (int i = 0; i < n; i++) {
    if (h[i] <= x && w[i] <= x && w[i] > h[i]) v.push_back(w[i] - h[i]);
    if (h[i] <= x && w[i] > x) continue;
    if (h[i] > x && w[i] <= x) res += h[i] - w[i], s++;
    if (h[i] > x && w[i] > x) return 1 << 30;
  }
  if (s > n / 2) return 1 << 30;
  int sz = v.size();
  int last = min(n / 2 - s, sz);
  sort(v.begin(), v.end());
  for (int i = sz - 1; i >= 0 && i > sz - 1 - last; i--) res -= v[i];
  return res * x;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &w[i], &h[i]);
    tot += w[i];
  }
  int ans = 1 << 30;
  for (int i = 0; i <= 1000; i++) ans = min(ans, f(i));
  printf("%d\n", ans);
  return 0;
}
