#include <bits/stdc++.h>   using namespace std;   long long n, k, a[300010], sum[300010], ans;   int main() {     scanf( %lld%lld , &n, &k);     for (int i = 1; i <= n; i++) scanf( %lld , &a[i]);     for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + a[i];     ans += k * sum[n];     sort(sum + 1, sum + n);     for (int i = 1; i < k; i++) ans -= sum[i];     printf( %lld , ans);     return 0;   }   