#1007. [Usaco2017 Feb]Why Did the Cow Cross the Road III

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

Description

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

Format

Input

Output

Samples

4
3
2
4
4
1
3
2
1
3

Hint

N<=100000