import math def main(): import sys input = sys.stdin.read().split() N = int(input[0]) A = list(map(int, input[1:N+1])) A.sort() max_A = A[-1] candidates = set() # Collect candidates from each A_i divided by k for a in A: if a == 0: continue sqrt_a = int(math.isqrt(a)) for k in range(1, sqrt_a + 1): x1 = a // k candidates.add(x1) candidates.add(x1 + 1) # Also handle the case where k > sqrt(a) for m in range(1, sqrt_a + 1): if m == 0: continue x2 = m if x2 <= sqrt_a: continue candidates.add(a // x2) candidates.add(a // x2 + 1) # Add X from 1 to sqrt(max_A) sqrt_max = int(math.isqrt(max_A)) + 1 for x in range(1, sqrt_max + 1): candidates.add(x) # Add X = max_A + 1 candidates.add(max_A + 1) # Convert to sorted list candidates = sorted(candidates) min_f = float('inf') best_x = -1 for x in candidates: if x <= 0: continue prev = -1 count = 0 for a in A: q = a // x if q != prev: count += 1 prev = q current_f = (x + 1) * count if current_f < min_f or (current_f == min_f and x < best_x): min_f = current_f best_x = x # Check X = max_A + 1 if not already considered x = max_A + 1 if x not in candidates: current_f = x + 1 if current_f < min_f or (current_f == min_f and x < best_x): min_f = current_f best_x = x print(best_x) print(min_f) if __name__ == "__main__": main()