import sys import math def input(): return sys.stdin.read() def is_possible(N, A): S = [a for a in A if a != 0] K = len(S) if K <= 1: return True S.sort() min_S = S[0] max_S = S[-1] # Check if all elements are the same if min_S == max_S: return True # Compute consecutive differences and their GCD diffs = [] for i in range(1, K): diffs.append(S[i] - S[i-1]) g = diffs[0] for d in diffs[1:]: g = math.gcd(g, d) if g == 0: return True # Generate all divisors of g def get_divisors(x): divisors = set() for i in range(1, int(math.isqrt(x)) + 1): if x % i == 0: divisors.add(i) divisors.add(x // i) return sorted(divisors, reverse=True) divisors = get_divisors(g) # Check each divisor for d in divisors: r = S[0] % d # Check if all elements in S have remainder r mod d valid = True for num in S: if num % d != r: valid = False break if not valid: continue # Check if (max_S - min_S) <= (N-1)*d if (max_S - min_S) > (N-1) * d: continue # Compute x0_low and x0_high x0_low = max(1, max_S - (N-1)*d) x0_high = min_S if x0_low > x0_high: continue # Check if there exists x0 in [x0_low, x0_high] such that x0 ≡ r mod d rem_want = r % d rem_low = x0_low % d delta = (rem_want - rem_low + d) % d candidate = x0_low + delta if candidate > x0_high: # No solution in this range continue else: return True return False data = input().split() N = int(data[0]) A = list(map(int, data[1:N+1])) if is_possible(N, A): print("Yes") else: print("No")