挺巧妙的数据结构题(不过据说这是一种套路?

E. Tufurama

One day Polycarp decided to rewatch his absolute favourite episode of well-known TV series "Tufurama". He was pretty surprised when he got results only for season 7 episode 3 with his search query of "Watch Tufurama season 3 episode 7 online full hd free". This got Polycarp confused — what if he decides to rewatch the entire series someday and won't be able to find the right episodes to watch? Polycarp now wants to count the number of times he will be forced to search for an episode using some different method.

TV series havenseasons (numbered1throughn), thei-th season hasaiepisodes (numbered1throughai). Polycarp thinks that if for some pair of integersxandy(x < y) exist both seasonxepisodeyand seasonyepisodexthen one of these search queries will include the wrong results. Help Polycarp to calculate the number of such pairs!

Input

The first line contains one integern(1  ≤ n  ≤  2·10^5)— the number of seasons.

The second line containsnintegers separated by spacea1, a2, ..., an(1 ≤ ai ≤ 10^9)— number of episodes in each season.

Output

Print one integer — the number of pairsxandy(x < y) such that there exist both seasonxepisodeyand seasonyepisodex.