欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1466A.Bovine Dilemma
Bovine Dilemma
Argus was charged with guarding Io, which is not an ordinary cow. Io is quite an explorer, and she wanders off rather frequently, making Argus' life stressful. So the cowherd decided to construct an enclosed pasture for Io.
There are trees growing along the river, where Argus tends Io. For this problem, the river can be viewed as the axis of the Cartesian coordinate system, and the trees as points with the -coordinate equal . There is also another tree growing in the point .
Argus will tie a rope around three of the trees, creating a triangular pasture. Its exact shape doesn't matter to Io, but its area is crucial to her. There may be many ways for Argus to arrange the fence, but only the ones which result in different areas of the pasture are interesting for Io. Calculate the number of different areas that her pasture may have. Note that the pasture must have nonzero area.
Input
The input consists of multiple test cases. The first line contains an integer () — the number of test cases. Then test cases follow, each one is described in two lines.
In the first line of each test case there is a single integer () denoting the number of trees growing along the river. Next line contains distinct integers $x_1 \lt x_2 \lt \ldots \lt x_{n - 1} \lt x_n$ (), the -coordinates of trees growing along the river.
Output
In a single line output an integer, the number of different nonzero areas that triangles with trees as vertices may have.
Note
In the first test case, we have non-degenerate triangles with the following areas: , , , , and . The pasture can have different areas, and thus is the answer.
In the second test case, we have non-degenerate triangles with the following areas: , and . The pasture can have different areas, so is the answer.
The following two drawings present the situation in the second test case. The blue triangles in the first drawing have area . The red triangle in the second drawing has area .

Samples
8
4
1 2 4 5
3
1 3 5
3
2 6 8
2
1 2
1
50
5
3 4 5 6 8
3
1 25 26
6
1 2 4 8 16 32
4
2
3
1
0
5
3
15
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |