We are given q queries. For each query, we have n goods with prices a_i. We need to set a single price x for all goods, such that the total revenue from selling all goods at price x is at least the total revenue from original prices (sum of a_i). Among all such x (presumably integer? The problem statement says "price" and examples output integer, but we need to check if x can be any real number? Usually in Codeforces problems, the price could be integer? Let's read carefully: "the i-th good costs a_i coins." coins are integer. "choose the same price for all n goods." "choose the minimum possible equal price". Since a_i are integers, and we want integer? In the examples, they output integer: for [1,2,3,4,5] sum=15, n=5, average=3, they output 3. For [1,2,2] sum=5, n=3, average=5/3≈1.666..., but they output 2. So they are outputting the ceiling of the average? Check: average of 1,2,2 = 5/3 = 1.666..., ceil is 2. For all ones, average=1, output 1. So indeed the answer is ceil( sum / n ). But wait, the condition: "sum of new prices is not less than the sum of the initial prices." New total revenue = n * x. Condition: n * x >= sum. So x >= sum / n. We need the minimum possible x that satisfies. Since x is a price (presumably in coins), we probably require x to be an integer because prices are in coins. So the minimal integer x such that x >= sum/n is ceil(sum/n). So answer = ceil( sum / n ). This matches examples.
But is there any nuance? n and a_i up to 100 and 1e7, sum can be up to 1e9, within int32. q up to 100. So trivial.
Thus solution: for each query, read n, array, compute sum, answer = (sum + n - 1) // n (integer ceiling). Output answer.
We should ensure that x is integer price. The problem statement: "price" and "coins", typical Codeforces problem "Equalize Prices" or something? Actually this seems like problem "A. Minimum Uniform Price" or something. Many problems ask to output ceil of average. Let's confirm: The condition is that total revenue is not less, but we also want to not lose customers because of big prices, so we want the minimum possible price among those that satisfy the condition. Since we can set any real number, the minimum would be exactly sum/n, but if we require integer? Typically the price must be integer coin amount. In sample, they output 2 for [1,2,2] while sum/n=1.666..., the minimal integer satisfying is 2. So indeed integer required. Usually problem statements specify "coins", implying integer. Some problems may say "You have to output integer" but not explicitly; but sample indicates integer. So answer is ceil.
Thus code: read q, loop, read n, read list a, compute s=sum(a), ans = (s + n - 1) // n, print ans.
Edge case: n=1, then answer = ceil(a1/1) = a1, which makes sense: you set price to at least original price, minimal is original price.
Ok.
But hold on: The problem statement: "You have to answer q independent queries." Input format: first line q, then each query: one line n, next line n integers. Output each answer on separate line.
Thus implement.
But wait: The problem might be from Codeforces Round #? Possibly titled "Ehab and subtraction"? Not sure. However, the solution is straightforward.
We need to output for each query.
Let's write final solution.
But we must be cautious: reading input: there may be multiple test cases; but using standard input.
Complexity: O(total n) per test.
We'll produce Python code.
But as the instruction says "You are both a shop keeper and a shop assistant..." It's a problem. So we can just output code.
Now, we also need to consider if there is any trick: maybe the price can be non-integer but we need the minimum real number, but output should be integer? The sample outputs integer. In many problems, they ask for "minimum possible equal price" and a_i are integers, but they expect ceil of average because price can be any real, but they want integer output? Usually the statement says "print the answer for it — the minimum possible equal price" and they output integer. So it's ambiguous: if price can be real, the minimum is exactly sum/n, which would be 1.666... for second query, but they output 2. So clearly they expect integer. So we assume integer price.
Thus done.
We'll write solution in Python.
But also, sometimes there is requirement that price must be integer? In problem "A. Equalize Prices Again" maybe? Let's check memory: I recall a Codeforces problem "A. Again Twenty Five!" not that. Another: "A. Uniform String"? Not.
Anyway, solution stands.
Now we craft the final answer: explanation and code.
We'll write:
def solve():
import sys
data = sys.stdin.read().strip().split()
it = iter(data)
q = int(next(it))
out = []
for _ in range(q):
n = int(next(it))
s = 0
for i in range(n):
s += int(next(it))
ans = (s + n - 1) // n
out.append(str(ans))
sys.stdout.write("\n".join(out))
or using list comprehension.
Testing with sample:
q=3
first: n=5, a=[1,2,3,4,5] sum=15, ans=(15+5-1)//5=19//5=3 -> ok
second: n=3, sum=5, ans=(5+3-1)//3=7//3=2 -> ok
third: n=4, sum=4, ans=(4+4-1)//4=7//4=1 -> ok.
Works.
Thus final answer.
But also note: n up to 100, a_i up to 1e7, sum up to 1e9, int in Python fine.
Thus we're done.
Now we output final solution with explanation. ```python
import sys
def solve() -> None:
data = sys.stdin.read().strip().split()
if not data:
return
it = iter(data)
q = int(next(it))
out_lines = []
for _ in range(q):
n = int(next(it))
total = 0
for _ in range(n):
total += int(next(it))
# minimal integer x with n*x >= total -> x = ceil(total / n)
ans = (total + n - 1) // n
out_lines.append(str(ans))
sys.stdout.write("\n".join(out_lines))
if name == "main":
solve()