Suit with a tie#8784

Suit with a tie

1 second
64 megabytes
Very easy

Irynka hosted a white slippers-themed party with a budget of pounds. guests attended, forming pairs. After the party, she wants to arrange them for a group photo. The guests are currently standing in a row, but Irynka is not satisfied with their arrangement. She wants each pair to stand next to each other to make the photo look more appealing.

Your task is to determine the minimum number of adjacent swaps needed to ensure that each pair stands together in the row.

Input

The first line contains a single integer (1 \leq n \leq 1000) – the number of pairs of people.

The second line contains integers a_1, a_2, \ldots, a_{2n}. For each that satisfies the condition 1 \leq i \leq n, the integer appears exactly twice in this list. If a_j = a_k = i, then the people at positions and form a pair.

Output

Output a single integer – the minimum number of swaps required.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading

Example 3

Loading
Loading