#include <bits/stdc++.h>
using namespace std;
vector<int> Joint(vector<int> X, vector<int> Y) {
  vector<int> Z;
  int m = X.size();
  int n = Y.size();
  for (int i = 0; i < m; i++) Z.push_back(X[i]);
  for (int i = 0; i < n; i++) Z.push_back(Y[i]);
  return Z;
}
int Min(vector<int> X) {
  int x = X[0];
  for (int i = 1; i < X.size(); i++) {
    if (X[i] < x) x = X[i];
  }
  return x;
}
int FindMin(vector<int> X) {
  int p;
  for (int i = 0; i < X.size(); i++) {
    if (X[i] == Min(X)) p = i;
  }
  return p;
}
vector<int> Subvec(vector<int> X, int p, int l) {
  vector<int> Y;
  for (int i = p; i < p + l; i++) Y.push_back(X[i]);
  return Y;
}
vector<int> SelectionSort(vector<int> A, int i) {
  int N = A.size() - 1;
  int p = FindMin(Subvec(A, i - 1, N - i + 1));
  if (p > i - 1) A[N]++;
  vector<int> B;
  B.push_back(A[p]);
  for (int j = i - 1; j < p; j++) B.push_back(A[j]);
  for (int j = p + 1; j < N; j++) B.push_back(A[j]);
  return Joint(Subvec(A, 0, i - 1), B);
}
void Output(vector<int> A) {
  int n = A.size() - 1;
  for (int i = 0; i < n; i++) cout << A[i] << ' ';
  cout << A[n] << endl;
}
int main() {
  int N;
  cin >> N;
  vector<int> A;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    A.push_back(a);
  }
  A.push_back(0);
  for (int i = 1; i < N; i++) A = SelectionSort(A, i);
  Output(Subvec(A, 0, N));
  cout << A[N] << endl;
  return 0;
}
