import math def main(): import sys input = sys.stdin.read().split() n = int(input[0]) A = list(map(int, input[1:n+1])) A = [a for a in A if a >= 0] # Remove negative values if any (though problem states 0 <= A1 < ...) if not A: print(1) print(2) return max_A = A[-1] candidates = set() # Generate candidates from each A_i for a in A: if a == 0: continue sqrt_a = int(math.isqrt(a)) for k in range(1, sqrt_a + 1): x = a // k candidates.add(x) candidates.add(x + 1) candidates.add(x - 1) # Also handle the case where k is up to a//1 (but covered by sqrt) # Add edge cases candidates.add(a) candidates.add(a + 1) candidates.add(a - 1) # Add max_A + 1 and 1 to 1e5 as threshold candidates.add(max_A + 1) for x in range(1, min(10**5, max_A + 2)): candidates.add(x) # Remove invalid candidates (X must be positive) candidates = {x for x in candidates if x > 0} candidates.add(1) # Ensure X=1 is considered candidates.add(max_A) candidates.add(max_A + 1) # Now compute for each candidate X min_f = float('inf') best_x = None A_sorted = sorted(A) for x in sorted(candidates): prev = None count = 0 for a in A_sorted: d = a // x if d != prev: count += 1 prev = d 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 print(best_x) print(min_f) if __name__ == '__main__': main()