King of Chairs

Arrange N ladies, each sitting or standing with probability 1/2, to maximize the expected number of ordered pairs where the person behind is strictly taller.

Hard8SortingGreedyProbabilityMathNo attempts yetTime limit1sMemory limit32 MB

Problem

King Uija of Baekje lined up NN court ladies in the palace front yard. The palace has 3,000 court ladies, but the front yard is narrow, so only NN of them stand in the line.

The king wants to dress their hair. The work goes faster when a person behind can see the head of a person in front of her. A person sees the head of every person ahead of her who is shorter than she is. A person in between who is taller than her, or exactly as tall as her, does not block the view, so she also sees the heads of the shorter people further ahead. The number of viewings in one arrangement is therefore the number of ordered pairs (person behind, person in front) in which the person behind is strictly taller than the person in front.

Court lady ii has sitting height SiS_i and standing height HiH_i. Each court lady sits on a chair with probability 1/21/2 and stands with probability 1/21/2, independently of every other court lady. Her height is SiS_i while she sits and HiH_i while she stands.

The king does not know who will sit and who will stand, so he cannot know the number of viewings, but he can know its expected value. He may put the court ladies in any order he likes. Write a program that finds the largest expected number of viewings he can reach.

Input

The first line contains the number of court ladies NN. (2N30002 \le N \le 3000)

Each of the next NN lines contains the sitting height SiS_i and the standing height HiH_i of one court lady, separated by a space. (1Si<Hi100001 \le S_i < H_i \le 10000) The court ladies are given in order, starting with the one standing at the very back.

Output

Print the largest expected number of viewings with exactly two digits after the decimal point. This value is always a multiple of 0.250.25, so two digits represent it exactly.