def main(): import sys input = sys.stdin.read().split() N = int(input[0]) A = list(map(int, input[1:N+1])) A = sorted(A) # Just in case, but input says it's already sorted max_A = A[-1] left = 1 right = max_A + 1 # Cover X up to max_A +1 def compute_f(X): if X == 0: return float('inf') prev = A[0] // X count = 1 for a in A[1:]: current = a // X if current != prev: count += 1 prev = current return (X + 1) * count # Ternary search to narrow down the range while right - left > 3: mid1 = left + (right - left) // 3 mid2 = right - (right - left) // 3 f1 = compute_f(mid1) f2 = compute_f(mid2) if f1 < f2: right = mid2 else: left = mid1 # Check all possible X in [left, right] inclusive min_f = float('inf') best_x = None for X in range(left, right + 1): current_f = compute_f(X) if current_f < min_f or (current_f == min_f and X < best_x): min_f = current_f best_x = X # Also check higher values if needed. Because when X > max_A, all elements are 0 except A >= X # Let's check X up to max_A +1 (included in initial range) # So the loop above should suffice print(best_x) print(min_f) if __name__ == "__main__": main()