AtCoder Beginner Contest 143
D
Triangles
AtCoder
⌀ 686
原题
← CE →
翻译中…

Problem Statement

翻译中…

Takahashi has $N$ sticks that are distinguishable from each other. The length of the $i$-th stick is $L_i$.

翻译中…

He is going to form a triangle using three of these sticks. Let $a$, $b$, and $c$ be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:

翻译中…
  • $a < b + c$
  • $b < c + a$
  • $c < a + b$
翻译中…

How many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.

翻译中…

Constraints

翻译中…
  • All values in input are integers.
  • $3 \leq N \leq 2 \times 10^3$
  • $1 \leq L_i \leq 10^3$
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N
L_1 L_2 ... L_N

翻译中…

Constraints

翻译中…

Print the number of different triangles that can be formed.

翻译中…

样例

Input #1
4
3 4 2 1
Output #1
1
Only one triangle can be formed: the triangle formed by the first, second, and third sticks.
Input #2
3
1 1000 1
Output #2
0
No triangles can be formed.
Input #3
7
218 786 704 233 645 728 389
Output #3
23
题目信息
题号
abc143_d
时间限制
2 s
内存限制
1024 MB

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