Many years have passed, and n friends met at a party again. Technologies have leaped forward since the last meeting, cameras with timer appeared and now it is not obligatory for one of the friends to stand with a camera, and, thus, being absent on the photo.

Simply speaking, the process of photographing can be described as follows. Each friend occupies a rectangle of pixels on the photo: the i-th of them in a standing state occupies a wi pixels wide and a hi pixels high rectangle. But also, each person can lie down for the photo, and then he will occupy a hi pixels wide and a wi pixels high rectangle.

The total photo will have size W × H, where W is the total width of all the people rectangles, and H is the maximum of the heights. The friends want to determine what minimum area the group photo can they obtain if no more than n / 2 of them can lie on the ground (it would be strange if more than n / 2 gentlemen lie on the ground together, isn't it?..)

Help them to achieve this goal.

Input

The first line contains integer n (1 ≤ n ≤ 1000) — the number of friends.

The next n lines have two integers wi, hi (1 ≤ wi, hi ≤ 1000) each, representing the size of the rectangle, corresponding to the i-th friend.

Output

Print a single integer equal to the minimum possible area of the photo containing all friends if no more than n / 2 of them can lie on the ground.

Examples

Input

3
10 1
20 2
30 3


Output

180


Input

3
3 1
2 2
4 3


Output

21


Input

1
5 10


Output

50
import java.util.function.Function;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.util.Comparator;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
import java.io.Writer;
import java.math.BigInteger;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Alex
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskB {
	class Block{
		int height;
		int width;
		public Block(int height, int width){
			this.height = height;
			this.width = width;
		}
	}
	public void solve(int testNumber, InputReader in, OutputWriter out){
		int n = in.ri();
		Block[] blocks = new Block[n];
		for(int i = 0; i < n; i++) {
			int a = in.ri(), b = in.ri();
			blocks[i] = new Block(b, a);
		}
		int min = Integer.MAX_VALUE;
		for(int maxheight = 1000; maxheight > 0; maxheight--) {
			Block[] copy = new Block[n];
			for(int i = 0; i < n; i++) copy[i] = new Block(blocks[i].height, blocks[i].width);
			int counter = 0;
			for(Block b : copy) {
				if(b.height > maxheight && b.width > maxheight){
					out.print(min);
					return;
				}
				int minval = Math.min(b.height, b.width), maxval = Math.max(b.height, b.width);
				if (b.height > maxheight){ //must switch, wrong now
					b.height = minval;
					b.width = maxval;
					counter++;
				}
			}
//			out.printLine(counter);
//			for(Block b : copy) out.printLine(b.width, b.height);
			Arrays.sort(copy, Comparator.comparing((Block x) -> x.height - x.width));
			for (Block b : copy) {
				if(counter == n / 2) break;
				if (b.width <= maxheight){
					int minval = Math.min(b.height, b.width), maxval = Math.max(b.height, b.width);
					b.width = minval;
					b.height = maxval;
					counter++;
				}
//				out.printLine("HERE");
			}
//			for(Block b : copy) out.printLine(b.width, b.height);
			if (counter > n / 2){
				out.print(min);
				return;
			}
			int curwidth = 0, curheight = 0;
			for(int i = 0; i < n; i++) curwidth += copy[i].width;
			for(int i = 0; i < n; i++) curheight = Math.max(curheight, copy[i].height);
//			out.printLine(maxheight, curwidth*curheight);
			min = Math.min(min, curwidth * curheight);
		}
		out.print(min);
	}
}

class InputReader {
	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}
	public int ri(){
		return readInt();
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return isWhitespace(c);
	}

	public static boolean isWhitespace(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}
	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}

class OutputWriter {
	private final PrintWriter writer;

	public OutputWriter(OutputStream outputStream) {
		writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
	}
	public void close() {
		writer.close();
	}
	public void print(int i) {
		writer.print(i);
	}
}

