A Math Problem
题号:NC273390
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

You are given an integer sequence a_1 \sim a_n.
There will be q queries. Each query provides an integer x. You need to calculate
\sum_{i=1}^{n}(a_i - x)^2 = (a_1 - x)^2 + (a_2 - x)^2 + ... + (a_n - x)^2

输入描述:

The first line contains two positive integers n, q, indicating the length of the sequence n and the number of queries q.
The second line contains n positive integers, representing each number in the sequence.
Next q lines each contain an integer, indicating the value of x for each query.

输出描述:

For each query, output one integer representing the answer.
示例1

输入

复制
3 3
1 2 3
1
2
3

输出

复制
5
2
5

说明

(1 - 1)^2 + (2 - 1)^2 + (3 - 1)^2 = 5
(1 - 2)^2 + (2 - 2)^2 + (3 - 2)^2 = 2
(1 - 3)^2 + (2 - 3)^2 + (3 - 3)^2 = 5

备注:

1 \le n, q \le 10^5, 1 \le x, a_i \le 10^5