Allen is hosting a formal dinner party with 2n guests who arrive as n pairs (couples). After the festivities, Allen wants everyone to line up for a final picture, but he prefers that each couple stands next to each other for a better aesthetic.
Your task is to help Allen determine the minimum number of adjacent swaps needed to arrange the guests such that each couple is adjacent in the lineup.
Problem Description
You need to write a function that takes the current order of guests and calculates the minimum number of adjacent swaps required to group each couple together.
Input Format
The first line contains a single integer n (1 ≤ n ≤ 100), the number of pairs of people.
The second line contains 2n integers, a_1, a_2, ..., a_{2n}, where each integer i (1 ≤ i ≤ n) appears exactly twice. If a_j = a_k = i, that means the j-th and k-th people in the line form a couple.
Output Format
Output a single integer, representing the minimum number of adjacent swaps needed to arrange the guests so that each pair occupies adjacent positions.
Examples
Input 1
text
4
1 1 2 3 3 2 4 4
Output 1
text
2
Input 2
text
3
1 1 2 2 3 3
Output 2
text
0
Input 3
text
3
3 1 2 3 1 2
Output 3
text
3
Notes
In the first example, a possible transformation is:
Start: 1 1 2 3 3 2 4 4
Step 1: 1 1 2 3 2 3 4 4 (1 swap)
Step 2: 1 1 2 2 3 3 4 4 (1 swap)
Total: 2 swaps.
The second example already satisfies the adjacency requirement, resulting in 0 swaps needed.
Implement your solution in the /app/ directory.
Important: place your implementation at /app/solution.py so the verifier can run it.