Jacob bought a new car last week, and he is going to test the capability of the car on a circular road this weekend. Now it's time to make a plan.

There are n gas stations lying on the circular road, labeled by 1, 2, 3, ... , n clockwise (as Fig.1 shows where n = 4). The ith station can supply c[i]
liter of gas to the car. Meanwhile, it costs d[i] liter of gas to drive from the ith station to its next station on the clockwise direction.

Jacob can choose any gas station to start and he is planning to travel one lap along the road clockwise and back to the starting station.
Obviously, choosing the proper starting station is critical. Otherwise the car may have to come to a halt in the midway because of the lack of
gas. But in some cases, no matter which gas station Jacob chooses to start, the trip can not be completed. Now here comes the problem: Given
the descriptions of the gas stations(c[i] and d[i]), you, his best friend, tell him whether he can complete the trip by choosing a proper starting
gas station. You may assume that the gasoline tank in the car is empty at the beginning and its capability is unlimited.

输入格式

The input contains several test cases. Each case begins with an integer n(1<=n<=50000), indicating the number of gas stations. The following

n integers are c[i] and the next n integers are d[i]. 1<=c[i],d[i]<=1000. All integers are separated by a single space or a newline character. The
input is terminated by n=0.

输出格式

For each test case, output "YES" if Jack can complete the trip, otherwise "NO" in a single line

样例输入

4
1 1 5 3
2 1 3 3
4
1 2 2 3
2 1 3 3
0

样例输出

YES
NO


#include<stdio.h>
int c[50001],d[50001];
int main(){
	int n,i,sumc,sumd;
	while(scanf("%d",&n)&&n!=0){
		sumc=0;sumd=0;
		for(i=1;i<=n;i++){
			scanf("%d",&c[i]);
			sumc=sumc+c[i];
		}
		for(i=1;i<=n;i++){
			scanf("%d",&d[i]);
			sumd=sumd+d[i];
		}
		if(sumc>=sumd)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}