Problem 5448. -- [Usaco2017 Feb]Why Did the Cow Cross the Road III

5448: [Usaco2017 Feb]Why Did the Cow Cross the Road III

Time Limit: 2 Sec  Memory Limit: 128 MB
Submit: 20  Solved: 11
[Submit][Status][Web Board]

Description

给定长度为2N的序列,1~N各处现过2次,i第一次出现位置记为ai,第二次记为bi,求满足ai<aj<bi<bj的对数


Input

Output

Sample Input

4

3

2

4

4

1

3

2

1

Sample Output

3

HINT

Source

[Submit][Status]