#C10935. Minimum Apple Purchase Cost
Minimum Apple Purchase Cost
Minimum Apple Purchase Cost
You are given n stalls and an integer m representing the maximum number of apples any stall can have. The second line contains n space-separated integers, where each integer represents the number of apples at a stall.
The cost of buying apples from any stall is defined as the square of the number of apples at that stall. In other words, if a stall has a_i apples, the cost is \(a_i^2\) (in \(\LaTeX\) format: \(a_i^2\)).
Your task is to determine the minimum cost to buy apples from exactly one stall.
inputFormat
The input is given via standard input (stdin) and consists of two lines:
The first line contains two integers n and m, where n is the number of stalls and m is the maximum number of apples a stall can have.
The second line contains n space-separated integers representing the number of apples in each stall.
outputFormat
Output a single integer via standard output (stdout), which is the minimum cost computed as (a_i^2) for the stall that minimizes this cost.## sample
5 10
3 7 2 9 5
4
</p>