#K53512. Synchronize Collections

    ID: 29548 Type: Default 1000ms 256MiB

Synchronize Collections

Synchronize Collections

Jane and Mark each have a collection of stones. Every stone is characterized by its size. Jane wants to synchronize her collection with Mark's collection by performing operations on her stones. In a single operation, Jane can increase or decrease the size of one stone by 1.

Your task is to compute the minimum total number of operations required so that for every corresponding stone in the two collections, the sizes become equal.

Mathematically, given two arrays A and B of length \(n\), you need to calculate:

[ \text{Operations} = \sum_{i=1}^{n} \left| A_i - B_i \right| ]

where \(A_i\) is the size of the \(i\)-th stone in Mark's collection and \(B_i\) is the size of the \(i\)-th stone in Jane's collection.

inputFormat

The input is provided via standard input (stdin) and has the following format:

  1. The first line contains an integer \(n\) which denotes the number of stones in each collection.
  2. The second line contains \(n\) space-separated integers representing the sizes of the stones in Mark’s collection.
  3. The third line contains \(n\) space-separated integers representing the sizes of the stones in Jane’s collection.

outputFormat

Output a single integer to standard output (stdout): the minimum total number of operations required to synchronize Jane's collection with Mark's collection.

## sample
3
3 5 7
4 6 8
3