Cards
Vasya and Petya are playing a card game. Vasya arranges two rows of cards on the table. The first row has n cards, each labeled with a number a_i. The second row also has n cards, each labeled with a number b_i.
Petya's goal is to rearrange the cards in the first row so that both rows become identical. Petya can swap the i-th card with the i+1-th card in the first row, and each swap takes one second (1 ≤ i ≤ n-1).
Your task is to determine the minimum time Petya needs to achieve this arrangement.
Input
The input starts with an integer n (1 ≤ n ≤ 100000). The second line contains n integers a_i. The third line contains n integers b_i. Each number is within the range of -10^6 to 10^6.
Output
Output the minimum number of seconds Petya needs to reorder the cards. If it is impossible to make the rows identical, output -1.