Generate python code that solves the following:

Spaceship Shuffle
Input File: spacein.txt
Output File: spaceout.txt
Welcome aboard, Captain! Today you are in charge of the first ever doughnut-shaped spaceship, The
Circular. There are N cabins arranged in a circle on the spaceship. They are numbered from 1 to N in
a clockwise direction around the ship. The ith and the (i + 1)th cabins are connected. So too are cabin
1 and cabin N .
Currently the ith cabin has Ai crewmates, however the spaceship cannot depart unless there are exactly
NAME_1 crewmates in this cabin.
To achieve this, you have the power to pay crewmates to change cabins. You can pay a crewmate $1 to
move to an adjacent cabin. A crewmate can be asked to move multiple times, provided that you pay
them $1 each time.
What is the fewest dollars you must pay before you can depart? It is always be possible to depart.
Figure 1: One possible solution to Sample Input 1, illustrated one move at a time. In each move, a
crewmate moves from the red cabin (dashed) to the green cabin. Cabin 1 is the topmost one.
Input
• The first line of input contains the integer N .
• The second line of input contains N integers describing the initial number of crewmates in each
cabin. They are A1, A2, . . . , AN .
• The third line of input contains N integers describing the desired number of crewmates in each
cabin. They are B1, B2, . . . , BN .
Output
You program must output one integer: the fewest dollars you must pay before you can depart.

Sample Input 1
6
5 2 1 6 5 1
3 3 2 7 3