fun readInt () = valOf (TextIO.scanStream (Int.scan StringCvt.DEC) TextIO.stdIn) fun isSatisfy n l min diff = let val checkList = Array.array (n, false) fun check nil = true | check (h::tl) = let val index = (h - min) div diff in if Array.sub (checkList, index) = false then ( ( Array.update (checkList, index, true); check tl ) ) else false end in if diff = 0 then false else check l end val () = let val n = readInt () val x_s = List.tabulate (n, fn _ => readInt ()) val (min, max) = List.foldl (fn (x, (minAcc, maxAcc)) => (Int.min (x, minAcc), Int.max (x, maxAcc))) (100000000, 0) x_s val d = (max - min) div (n - 1) val ans = if isSatisfy n x_s min d then "YES" else "NO" in print (ans ^ "\n") end