{"raw_statement":[{"iden":"problem statement","content":"You are given a sequence $A = (A_1, A_2, \\ldots, A_N)$ of positive integers and a positive integer $X$. You can perform the operation below any number of times, possibly zero:\n\n*   Choose an index $i$ ($1\\leq i\\leq N$) and a non-negative integer $x$ such that $0\\leq x\\leq X$. Change $A_i$ to $2A_i+x$.\n\nFind the smallest possible value of $\\max{A_1,A_2,\\ldots,A_N}-\\min{A_1,A_2,\\ldots,A_N}$ after your operations."},{"iden":"constraints","content":"*   $2\\leq N\\leq 10^5$\n*   $1\\leq X\\leq 10^9$\n*   $1\\leq A_i\\leq 10^9$"},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$ $X$\n$A_1$ $A_2$ $\\ldots$ $A_N$"},{"iden":"sample input 1","content":"4 2\n5 8 12 20"},{"iden":"sample output 1","content":"6\n\nLet $(i, x)$ denote an operation that changes $A_i$ to $2A_i+x$. An optimal sequence of operations is\n\n*   $(1,0)$, $(1,1)$, $(2,2)$, $(3,0)$\n\nwhich yields $A = (21, 18, 24, 20)$, achieving $\\max{A_1,A_2,A_3,A_4}-\\min{A_1,A_2,A_3,A_4} = 6$."},{"iden":"sample input 2","content":"4 5\n24 25 26 27"},{"iden":"sample output 2","content":"0\n\nAn optimal sequence of operations is\n\n*   $(1,5)$, $(1,5)$, $(2,5)$, $(2,1)$, $(3,2)$, $(3,3)$, $(4,0)$, $(4,3)$\n\nwhich yields $A = (111,111,111,111)$, achieving $\\max{A_1,A_2,A_3,A_4}-\\min{A_1,A_2,A_3,A_4} = 0$."},{"iden":"sample input 3","content":"4 1\n24 25 26 27"},{"iden":"sample output 3","content":"3\n\nPerforming no operations achieves $\\max{A_1,A_2,A_3,A_4}-\\min{A_1,A_2,A_3,A_4} = 3$."},{"iden":"sample input 4","content":"10 5\n39 23 3 7 16 19 40 16 33 6"},{"iden":"sample output 4","content":"13"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}