Under construction

Still being built. Things may change

Tashu

Interview

Time limit1sMemory limit1024 MB

Summary
Given current and target bike counts per station, find the minimum number of single-bike moves to reach the target counts.
Level

Easy3 of 10

Topics
Greedy, Prefix sum
Solved
No attempts yet

Problem

Tashu is a public bike rental service run by Daejeon city. Citizens can rent a bike from an unattended rental station and must return it to an unattended rental station when they finish. The bike does not have to go back to the station where it was rented. It can be returned to any station.

The city installed NN rental stations and placed a1,a2,⋯ ,aNa_1, a_2, \cdots, a_N bikes at each station, based on expected demand, then started the service. Some time later, to improve service quality, the city suspended Tashu and had every bike returned to a station. Fortunately no bike was lost, but the number of bikes at each station became b1,b2,⋯ ,bNb_1, b_2, \cdots, b_N.

Youngwoo, who works for the Daejeon city government, wants to restore the number of bikes at each station to a1,a2,⋯ ,aNa_1, a_2, \cdots, a_N before service resumes. Youngwoo can pick up one bike at station ii on foot and carry it to station jj. Find the minimum number of bikes Youngwoo must move.

Input

The first line contains an integer N(2≤N≤100)N(2\le N\le 100).

The second line contains integers a1,a2,⋯ ,aN(1≤ai≤100)a_1, a_2, \cdots, a_N(1\le a_i\le 100) separated by spaces.

The third line contains integers b1,b2,⋯ ,bN(1≤bi≤100)b_1, b_2, \cdots, b_N(1\le b_i\le 100) separated by spaces.

The sum a1+a2+⋯+aNa_1+a_2+\cdots+a_N equals b1+b2+⋯+bNb_1+b_2+\cdots+b_N.

Output

Print the minimum number of times bikes must be moved so that the number of bikes at each station becomes a1,a2,⋯ ,aNa_1, a_2, \cdots, a_N.

Examples3

  1. Example 1

    Input
    4
    3 1 4 2
    2 2 3 3
    
    Expected output
    2
    
  2. Example 2

    Input
    3
    1 1 5
    4 2 1
    
    Expected output
    4
    
  3. Example 3

    Input
    2
    2 1
    2 1
    
    Expected output
    0