#include <bits/stdc++.h>   using namespace std;   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long n, k, x, s = 0;     cin >> n >> k;     map<long long, long long> m;     queue<long long> q;     for (long long i = 0; 0 < n ? i < n : i > n; 0 < n ? i += 1 : i -= 1) {       cin >> x;       q.push(x);       m[x] = 0;     }     while (1) {       x = q.front();       q.pop();       if (!m.count(x + 1)) {         q.push(x + 1);         m[x + 1] = m[x] + 1;       }       if (m.size() >= n + k) break;       if (!m.count(x - 1)) {         q.push(x - 1);         m[x - 1] = m[x] + 1;       }       if (m.size() >= n + k) break;     }     for (auto i : m) s += i.second;     cout << s <<   n ;     for (auto i : m)       if (i.second != 0) cout << i.first <<    ;   }   