{"raw_statement":[{"iden":"problem statement","content":"We will play a one-player game using a number line and $N$ pieces.\nFirst, we place each of these pieces at some integer coordinate.\nHere, multiple pieces can be placed at the same coordinate.\nOur objective is to visit all of the $M$ coordinates $X_1, X_2, ..., X_M$ with these pieces, by repeating the following move:\n**Move**: Choose a piece and let $x$ be its coordinate. Put that piece at coordinate $x+1$ or $x-1$.\nNote that the coordinates where we initially place the pieces are already regarded as visited.\nFind the minimum number of moves required to achieve the objective."},{"iden":"constraints","content":"*   All values in input are integers.\n*   $1 \\leq N \\leq 10^5$\n*   $1 \\leq M \\leq 10^5$\n*   $-10^5 \\leq X_i \\leq 10^5$\n*   $X_1, X_2, ..., X_M$ are all different."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$ $M$\n$X_1$ $X_2$ $...$ $X_M$"},{"iden":"sample input 1","content":"2 5\n10 12 1 2 14"},{"iden":"sample output 1","content":"5\n\nThe objective can be achieved in five moves as follows, and this is the minimum number of moves required.\n\n*   Initially, put the two pieces at coordinates $1$ and $10$.\n*   Move the piece at coordinate $1$ to $2$.\n*   Move the piece at coordinate $10$ to $11$.\n*   Move the piece at coordinate $11$ to $12$.\n*   Move the piece at coordinate $12$ to $13$.\n*   Move the piece at coordinate $13$ to $14$."},{"iden":"sample input 2","content":"3 7\n-10 -3 0 9 -100 2 17"},{"iden":"sample output 2","content":"19"},{"iden":"sample input 3","content":"100 1\n-100000"},{"iden":"sample output 3","content":"0"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}