#include <bits/stdc++.h>   using namespace std;   const long long BIG = 1000000000000000000LL;   void solve();   signed main() {     ios::sync_with_stdio(false);     cin.tie(0);     solve();     return 0;   }   const long long borne = 3 * (long long)(1e5) + 5;   long long tab[borne];   long long som[borne];   long long nbElem, nbParties;   void solve() {     cin >> nbElem >> nbParties;     for (long long i = (0); i < (nbElem); ++i) {       cin >> tab[i];     }     som[0] = tab[0];     for (long long i = (1); i < (nbElem); ++i) som[i] = tab[i] + som[i - 1];     vector<long long> ww(nbElem - 1);     for (long long i = (0); i < (nbElem - 1); ++i) ww[i] = som[i];     sort(ww.begin(), ww.end());     long long res = nbParties * som[nbElem - 1];     for (long long i = (0); i < (nbParties - 1); ++i) res -= ww[i];     cout << res <<   n ;   }   