Task
Doctor Strange found two integer arrays of length , namely and .
He can perform the following operation on any number of times:
- Choose an index and let . That is, assign the value to .
Help the Doctor determine whether it is possible to make the array equal to and if so, then find the minimum number of operations required to achieve this.
Input data
The first line contains the only integer .
The second line contains integers, the elements of array .
The third line contains integers, the elements of array .
Output data
You need to write a single line with an integer: the minimum number of operations required to make equal to , or if it is not possible to do so.
Constraints and clarifications
- .
- for each .
Scoring
In this task, you can get partial scores: you will get of the points for a subtask if you successfully determine whether it is possible to make equal to (but do not correctly solve all of its test cases).
For this, the following condition must be satisfied for all test cases in a subtask: you should output whenever it is impossible to make the two arrays equal, and otherwise, you should output a non-negative integer between and .
# | Points | Constraints |
---|---|---|
1 | 0 | Examples. |
2 | 15 | There is at most one non-zero number in |
3 | 18 | |
4 | 50 | |
5 | 17 | No additional limitations. |
Example 1
stdin
6
2 7 1 8 2 8
2 -10 1 -11 1 8
stdout
3
Explanation
In the first sample case, consider the following steps for the array :
- Perform the operation on index . The array becomes: .
- Perform the operation on index . The array becomes: .
- Perform the operation on index . The array becomes: .
It is not possible to make the two arrays equal in less than moves.
Example 2
stdin
4
3 1 4 1
-4 1 -6 1
stdout
-1
Explanation
In the second sample case, it can be proven that there is no way to make equal to using the described operation.