#include <bits/stdc++.h>
using namespace std;
long long int a[3000], b[3000];
bool swp[3000] = {0};
int main() {
  int n;
  cin >> n;
  long long int sum = 0, maxi = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i] >> b[i];
    sum += a[i];
    maxi = max(maxi, b[i]);
  }
  long long int res = sum * maxi;
  for (int f = 1; f <= 1000; f++) {
    for (int j = 1; j <= n; j++) swp[j] = 0;
    int k = f;
    int cnt = 0;
    vector<long long int> advantage;
    long long int updatedsum = 0;
    bool psbl = 1;
    for (int j = 1; j <= n; j++) {
      if (b[j] > k) {
        if (a[j] > k) {
          psbl = 0;
          break;
        }
        swp[j] = 1;
        cnt++;
      }
    }
    if (2 * cnt > n || (!psbl)) continue;
    for (int j = 1; j <= n; j++) {
      if (swp[j])
        updatedsum += b[j];
      else {
        updatedsum += a[j];
        if (a[j] <= k && (b[j] < a[j])) {
          advantage.push_back(a[j] - b[j]);
        }
      }
    }
    for (int p = 1; p <= n; p++) advantage.push_back(0);
    sort(advantage.begin(), advantage.end());
    for (int j = advantage.size() - 1; j >= 0; j--) {
      if (2 * (cnt + 1) > n) break;
      cnt++;
      updatedsum -= (advantage[j]);
    }
    res = min(res, updatedsum * k);
  }
  cout << res << endl;
}
