Cards#1026

Cards

1 second
64 megabytes
Hard

Two players are playing a game. The first player places two rows of cards on the table. The first row has cards, each card labeled with a number a_i. The second row also has cards, each card labeled with a number b_i.

The second player must rearrange the cards in the first row so that both rows are identical. The second player can swap the -th and (i+1)-th cards in the first row in one second, where 1 \leq i \leq n-1.

Help the second player reorder the cards in the minimum possible time.

Input

The first line contains an integer (1 \leq n \leq 100000).

The second line contains integers a_i.

The third line contains integers b_i.

All numbers are between -10^6 and 10^6 inclusively.

Output

Output the minimum number of seconds the second player needs to rearrange the cards. If it is impossible, output .

Examples

Example 1

Loading
Loading