Codeforces Beta Round 57 (Div. 2)
E
Enemy is weak
Codeforces
1900
原题
← D→
翻译中…

The Romans have attacked again. This time they are much more than the Persians but Shapur is ready to defeat them. He says: "A lion is never afraid of a hundred sheep".

翻译中…

Nevertheless Shapur has to find weaknesses in the Roman army to defeat them. So he gives the army a weakness number.

翻译中…

In Shapur's opinion the weakness of an army is equal to the number of triplets $*i*, *j*, *k*$ such that $*i* < *j* < *k*$ and $*a*_{*i*} > *a*_{*j*} > *a*_{*k*}$ where $*a*_{*x*}$ is the power of man standing at position $*x*$. The Roman army has one special trait — powers of all the people in it are distinct.

翻译中…

Help Shapur find out how weak the Romans are.

翻译中…

Input

翻译中…

The first line of input contains a single number $*n*$ ($3 ≤ *n* ≤ 10^{6}$) — the number of men in Roman army. Next line contains $*n*$ different positive integers $*a*_{*i*}$ ($1 ≤ *i* ≤ *n*, 1 ≤ *a*_{*i*} ≤ 10^{9}$) — powers of men in the Roman army.

翻译中…

Output

翻译中…

A single integer number, the weakness of the Roman army.

翻译中…

Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cout (also you may use %I64d).

翻译中…

样例

Input #1
3
3 2 1
Output #1
1
InputCopy OutputCopy
Input #2
3
2 3 1
Output #2
0
InputCopy OutputCopy
Input #3
4
10 8 3 1
Output #3
4
InputCopy OutputCopy
Input #4
4
1 5 4 3
Output #4
1
InputCopy OutputCopy
题目信息
题号
61E
时间限制
5 s
内存限制
256 MB
标签
数据结构
树

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。