#include <iostream>
#include <vector>
int main() {
int n, m;
std::cin >> n >> m;
if (m < 0 || m > 1000) {
std::cerr << "Invalid number of elements. Please enter a number between 0 and 1000." << std::endl;
return 1;
}
std::vector<int> arr(m);
for (int i = 0; i < m; ++i) {
std::cin >> arr[i];
}
// Find the position to insert the new number
int pos = 0;
while (pos < m && arr[pos] < n) {
++pos;
}
// Insert the number into the correct position
arr.insert(arr.begin() + pos, n);
// Output the new sorted array
for (const int& num : arr) {
std::cout << num << " ";
}
std::cout << std::endl;
return 0;
}
/**************************************************************
Problem: 1161
User: zhenghaoxuan
Language: C++
Result: Accepted
Time:9 ms
Memory:2076 kb
****************************************************************/