프로그램 명: coci_perket
제한시간: 1 초

퍼켓은 매우 유명하고 맛있는 식사다. 제대로 된 맛을 얻기 위해서는 재료를 잘 선택해야 한다.

당신은 N 가지의 재료를 가지고 있다. 각 재료의 신맛을 S , 썬맛을 B 라고 하자. 여러가지 재료를 사용할 때 , 전체의 신 맛은 각 재료의 썬맛의 곱이고 전체의 썬 맛은 각 재료의 합이다.

모두가 알 듯이 , 퍼켓은 시어시도 써서도 안된다. 신맛과 썬맛의 차이를 가장 최소로 할 수 있는 재료를 선택하길 원한다.

적어도 한가지 이상의 재료를 선택해야 하고 물을 탈 수는 없다.


"Perket" is a widely known and delicious meal. For perket to be what it is, cooks must carefully choose the ingredients to get the fullest taste possible while keeping the meal traditional.

You have N ingredients at your disposal. For each we know its sourness S and bitterness B. When using multiple ingredients, the total sourness is the product of sourness amounts of all ingredients, while the total bitterness is the sum of bitterness amounts of all ingredients.

As everyone knows, perket is supposed to be neither sour nor bitter; we want to choose the ingredients so that the absolute difference between sourness and bitterness is the smallest.

Also, it is necessary to use at least one ingredient; you can't serve water as the main course.

입력

The input data will be such that, if we make a meal with all ingredients, both the sourness and bitterness will be less than 1000000000.

출력

Output the smallest possible difference between sourness and bitterness.

입출력 예

input 

1 
3 10 

output 

7 

input 

2 
3 8 
5 8 

output 

1 

input 

4 
1 7 
2 6 
3 8 
4 9 

output 

1 

EXAMPLES

In the third example, we choose the last three ingredients. The total sourness is then 2·3·4=24 and bitterness is 6+8+9=23. The difference is 1
출처: coci 2008/2009 3/6

[질/답] [제출 현황] [푼 후(0)]
[ 채 점 ] [홈으로]  [뒤 로]