In the year 2168, AtCoder Inc., which is much larger than now, is starting a limited express train service called AtCoder Express.

In the plan developed by the president Takahashi, the trains will run as follows:

* A train will run for (t_1 + t_2 + t_3 + ... + t_N) seconds.
* In the first t_1 seconds, a train must run at a speed of at most v_1 m/s (meters per second). Similarly, in the subsequent t_2 seconds, a train must run at a speed of at most v_2 m/s, and so on.



According to the specifications of the trains, the acceleration of a train must be always within ±1m/s^2. Additionally, a train must stop at the beginning and the end of the run.

Find the maximum possible distance that a train can cover in the run.

Constraints

* 1 \leq N \leq 100
* 1 \leq t_i \leq 200
* 1 \leq v_i \leq 100
* All input values are integers.

Input

Input is given from Standard Input in the following format:


N
t_1 t_2 t_3 … t_N
v_1 v_2 v_3 … v_N


Output

Print the maximum possible that a train can cover in the run.
Output is considered correct if its absolute difference from the judge's output is at most 10^{-3}.

Examples

Input

1
100
30


Output

2100.000000000000000


Input

2
60 50
34 38


Output

2632.000000000000000


Input

3
12 14 2
6 2 7


Output

76.000000000000000


Input

1
9
10


Output

20.250000000000000000


Input

10
64 55 27 35 76 119 7 18 49 100
29 19 31 39 27 48 41 87 55 70


Output

20291.000000000000
def get_distance_and_next_speed(current_speed, max_speed, time, next_max_speed):
	#CASE 1: /---- or -----(CAN REACH THE MAX SPEED) AND THE NEXT MAX SPEED IS EQUAL TO OR BIGGER THAN CURRENT MAX SPEED
	if max_speed <= next_max_speed and max_speed >= current_speed and max_speed - current_speed <= time:
		#max_speed - current_speed = THE DELTA VELOCITY = THE DELTA TIME < t --> CAN REACH THE MAX SPEED
		acceleration_duration = max_speed - current_speed
		max_speed_duration = time - acceleration_duration
		distance = ((max_speed + current_speed) * acceleration_duration) / 2.0 + max_speed_duration * max_speed
		new_current_speed = max_speed
		return distance, new_current_speed, 1
	
	#CASE 2: /(CAN NOT REACH THE MAX SPEED) AND THE NEXT MAX SPEED IS EQUAL TO OR BIGGER THAN CURRENT MAX SPEED
	elif max_speed <= next_max_speed and max_speed > current_speed and max_speed - current_speed > time:
		#CAN NOT REACH THE MAX SPEED IN THIS DURATION
		max_valid_speed = current_speed + time
		distance = (max_valid_speed + current_speed) * time / 2.0
		new_current_speed = max_valid_speed
		return distance, new_current_speed, 2
	
	#CASE 3: /--\ or --\ THE SUM OF VELOCITY CHANGING DURATION SHALL BE EQUAL TO OR SMALLER THAN TIME
	elif max_speed > next_max_speed and max_speed >= current_speed and (max_speed - current_speed) + (max_speed - next_max_speed) <= time:
		#ACCELERATION PART
		acceleration_duration = max_speed - current_speed
		acceleration_distance = (max_speed + current_speed) * acceleration_duration / 2.0
		
		#MAX SPEED PART				#THE DELTA TIME OF ACCELERATION #THE DELTA TIME OF DECELERATION
		max_speed_duration = time - ((max_speed - current_speed) + (max_speed - next_max_speed))
		max_speed_distance = max_speed_duration * max_speed
		
		#DECELERATION PART
		deceleration_duration = max_speed - next_max_speed
		deceleration_distance = deceleration_duration * (max_speed + next_max_speed) / 2.0
		
		distance = acceleration_distance + max_speed_distance + deceleration_distance
		new_current_speed = next_max_speed
		return distance, new_current_speed, 3
	
	#CASE 4: /\ THAT IS IMPOSSIBLE TO REACH THE MAX VELOCITY
	elif max_speed > next_max_speed and max_speed > current_speed and (max_speed - current_speed) + (max_speed - next_max_speed) > time:
		#CASE 1 ONLY / WITH NO DECELERATION
		if current_speed + time <= next_max_speed:
			distance = (current_speed + current_speed + time) * time / 2.0
			new_current_speed = current_speed + time
			return distance, new_current_speed, 4
		
		#CASE 2 /\
		else:
			acceleration_duration = (next_max_speed - current_speed + time) / 2.0
			deceleration_duration = time - acceleration_duration
			max_valid_speed = current_speed + acceleration_duration
			
			#ACCELERATION PART
			acceleration_distance = (max_valid_speed + current_speed) * acceleration_duration / 2.0
			
			#DECELERATION PART
			deceleration_distance = (max_valid_speed + next_max_speed) * deceleration_duration / 2.0
			
			distance = acceleration_distance + deceleration_distance
			new_current_speed = next_max_speed
			return distance, new_current_speed, 4

case_number = input()
time_list = [int(x) for x in raw_input().split()]
velocity_list = [int(x) for x in raw_input().split()]
velocity_list.append(0)	#THE FINAL DECELERATION CAN BE SEEN AS A PART WHOSE MAX VELOCITY IS ZERO
#PREPROCESS TO SIMPLIFY CASES
velocity_list = velocity_list[::-1]
time_list = time_list[::-1]

for vi in xrange(len(velocity_list) - 1):
	cur_v = velocity_list[vi]
	next_v = velocity_list[vi + 1]
	duration_time = time_list[vi]
	next_v = min(next_v, cur_v + duration_time)
	velocity_list[vi + 1] = next_v

velocity_list = velocity_list[::-1]
time_list = time_list[::-1]

CURRENT_SPEED = 0
TOTAL_DISTANCE = 0
DISTANCE_LIST = [0]
SPEED_LIST = [0]

for INDEX in xrange(case_number):
	#print CURRENT_SPEED, velocity_list[INDEX], time_list[INDEX], velocity_list[INDEX + 1]
	DELTA_DISTANCE, CURRENT_SPEED, STATUS = get_distance_and_next_speed(current_speed = CURRENT_SPEED, max_speed = velocity_list[INDEX], time = time_list[INDEX], next_max_speed = velocity_list[INDEX + 1])
	DISTANCE_LIST.append(DELTA_DISTANCE)
	TOTAL_DISTANCE += DELTA_DISTANCE
	SPEED_LIST.append(CURRENT_SPEED)

print '%.10f' % TOTAL_DISTANCE