output_description: Find the minimum number of moves required to achieve the objective.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N M
      X_1 X_2 ... X_M
attempt: # coding: utf-8
  import sys
  
  # import bisect
  # import math
  # import numpy as np
  
  
  """Template"""
  
  
  class IP:
      """
      入力を取得するクラス
      """
  
      def __init__(self):
          self.input = sys.stdin.readline
  
      def I(self):
          """
          1文字の取得に使います
          :return: int
          """
          return int(self.input())
  
      def S(self):
          """
          1文字の取得(str
          :return: str
          """
          return self.input()
  
      def IL(self):
          """
          1行を空白で区切りリストにします(int
          :return: リスト
          """
          return list(map(int, self.input().split()))
  
      def SL(self):
          """
          1行の文字列を空白区切りでリストにします
          :return: リスト
          """
          return list(map(str, self.input().split()))
  
      def ILS(self, n):
          """
          1列丸々取得します(int
          :param n: 行数
          :return: リスト
          """
          return [int(self.input()) for _ in range(n)]
  
      def SLS(self, n):
          """
          1列丸々取得します（str
          :param n: 行数
          :return: リスト
          """
          return [self.input() for _ in range(n)]
  
      def SILS(self, n):
          """
          Some Int LineS
          横に複数、縦にも複数
          :param n: 行数
          :return: list
          """
          return [self.IL() for _ in range(n)]
  
      def SSLS(self, n):
          """
          Some String LineS
          :param n: 行数
          :return: list
          """
          return [self.SL() for _ in range(n)]
  
  
  class Idea:
      def __init__(self):
          pass
  
      def HF(self, p):
          """
          Half enumeration
          半分全列挙です
          pの要素の和の組み合わせを作ります。
          ソート、重複削除行います
          :param p: list : 元となるリスト
          :return: list : 組み合わせられた和のリスト
          """
          return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))
  
      def Bfs2(self, a):
          """
          bit_full_search2
          bit全探索の改良版
          全探索させたら2進数のリストと10進数のリストを返す
          :return: list２つ : １個目 2進数(16桁)  2個目 10進数
          """
          # 参考
          # https://blog.rossywhite.com/2018/08/06/bit-search/
          # https://atcoder.jp/contests/abc105/submissions/4088632
          value = []
          for i in range(1 << len(a)):
              output = []
  
              for j in range(len(a)):
                  if self.bit_o(i, j):
                      """右からj+1番目のiが1かどうか判定"""
                      # output.append(a[j])
                      output.append(a[j])
              value.append([format(i, "b").zfill(16), sum(output)])
  
          value.sort(key=lambda x: x[1])
          bin = [value[k][0] for k in range(len(value))]
          val = [value[k][1] for k in range(len(value))]
          return bin, val
  
      def S(self, s, r=0, m=-1):
          """
          ソート関係行います。色々な設定あります。
          :param s: 元となるリスト
          :param r: reversするかどうか 0=False 1=True
          :param m: （2次元配列）何番目のインデックスのソートなのか
          :return: None
          """
          r = bool(r)
          if m == -1:
              s.sort(reverse=r)
          else:
              s.sort(reverse=r, key=lambda x: x[m])
  
      def bit_n(self, a, b):
          """
          bit探索で使います。0以上のときにTrue出します
          自然数だからn
          :param a: int
          :param b: int
          :return: bool
          """
          return bool((a >> b & 1) > 0)
  
      def bit_o(self, a, b):
          """
          bit探索で使います。1のときにTrue出すよ
          oneで1
          :param a: int
          :param b: int
          :return: bool
          """
          return bool(((a >> b) & 1) == 1)
  
      def ceil(self, x, y):
          """
          Round up
          小数点切り上げ割り算
          :param x: int
          :param y: int
          :return: int
          """
          return -(-x // y)
  
      def ave(self, a):
          """
          平均を求めます
          :param a: list
          :return: int
          """
          return sum(a) / len(a)
  
  
  """ここからメインコード"""
  
  
  def main():
      # 1文字に省略
      r, e = range, enumerate
      ip = IP()
      id = Idea()
  
      """この下から書いてね"""
      n, m = ip.IL()
      x = ip.IL()
  
      id.S(x)
      s = []
      for i in r(0, m - 1):
          s.append(x[i + 1] - x[i])
  
      id.S(s, 1)
      if m == 1:
          print(0)
  
      elif len(s) >= m:
          print(0)
  
      else:
          for _ in r(n - 1):
              s.pop(0)
              if len(s) == 0:
                  break
          print(sum(s))
  
  
  main()
  
problem_description: Statement
  
  We will play a one-player game using a number line and N pieces.
  
  First, we place each of these pieces at some integer coordinate.
  
  Here, multiple pieces can be placed at the same coordinate.
  
  Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with
  these pieces, by repeating the following move:
  
  **Move** : Choose a piece and let x be its coordinate. Put that piece at
  coordinate x+1 or x-1.
  
  Note that the coordinates where we initially place the pieces are already
  regarded as visited.
  
  Find the minimum number of moves required to achieve the objective.
samples: [{"input": "2 5\n    10 12 1 2 14", "output": "5\n    \n\nThe objective can be achieved in five moves as follows, and this is the\nminimum 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.\n\n* * *"}, {"input": "3 7\n    -10 -3 0 9 -100 2 17", "output": "19\n    \n\n* * *"}, {"input": "100 1\n    -100000", "output": "0"}]