import java.io.*;
import java.util.StringTokenizer;
  
class Main{
  
static final PrintWriter out=new PrintWriter(System.out);
static int ans=0;
  
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line);
int[] a=new int[n];
StringTokenizer st=new StringTokenizer(br.readLine());
for(int i=0;i<n;i++) a[i]=Integer.parseInt(st.nextToken());
SelectionSort(a);
getValue(a);
out.println(ans);
out.flush();
}
}
  
private static void swap(int[] a,int s,int t){
int tmp=a[s]; a[s]=a[t]; a[t]=tmp; ans++;
}
  
private static void SelectionSort(int[] a){
for(int i=0;i<a.length-1;i++){
int min=i;
for(int j=i+1;j<a.length;j++){
if(a[j]<a[min]) min=j;
}
if(i!=min) swap(a,i,min);
}
}
  
private static void getValue(int[] a){
for(int i=0;i<a.length-1;i++) out.print(a[i]+" ");
out.println(a[a.length-1]);
}
} import java.io.*; io.* java import java.util.StringTokenizer; StringTokenizer java.util class Main{
  
static final PrintWriter out=new PrintWriter(System.out);
static int ans=0;
  
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line);
int[] a=new int[n];
StringTokenizer st=new StringTokenizer(br.readLine());
for(int i=0;i<n;i++) a[i]=Integer.parseInt(st.nextToken());
SelectionSort(a);
getValue(a);
out.println(ans);
out.flush();
}
}
  
private static void swap(int[] a,int s,int t){
int tmp=a[s]; a[s]=a[t]; a[t]=tmp; ans++;
}
  
private static void SelectionSort(int[] a){
for(int i=0;i<a.length-1;i++){
int min=i;
for(int j=i+1;j<a.length;j++){
if(a[j]<a[min]) min=j;
}
if(i!=min) swap(a,i,min);
}
}
  
private static void getValue(int[] a){
for(int i=0;i<a.length-1;i++) out.print(a[i]+" ");
out.println(a[a.length-1]);
}
} Main static final PrintWriter out=new PrintWriter(System.out); out new PrintWriter(System.out) static int ans=0; ans 0 public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line);
int[] a=new int[n];
StringTokenizer st=new StringTokenizer(br.readLine());
for(int i=0;i<n;i++) a[i]=Integer.parseInt(st.nextToken());
SelectionSort(a);
getValue(a);
out.println(ans);
out.flush();
}
} main {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line);
int[] a=new int[n];
StringTokenizer st=new StringTokenizer(br.readLine());
for(int i=0;i<n;i++) a[i]=Integer.parseInt(st.nextToken());
SelectionSort(a);
getValue(a);
out.println(ans);
out.flush();
}
} BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String line=""; line "" while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line);
int[] a=new int[n];
StringTokenizer st=new StringTokenizer(br.readLine());
for(int i=0;i<n;i++) a[i]=Integer.parseInt(st.nextToken());
SelectionSort(a);
getValue(a);
out.println(ans);
out.flush();
} (line=br.readLine())!=null&&!line.isEmpty() (line=br.readLine())!=null (line=br.readLine()) line br.readLine() br.readLine br null !line.isEmpty() line.isEmpty() line.isEmpty line {
int n=Integer.parseInt(line);
int[] a=new int[n];
StringTokenizer st=new StringTokenizer(br.readLine());
for(int i=0;i<n;i++) a[i]=Integer.parseInt(st.nextToken());
SelectionSort(a);
getValue(a);
out.println(ans);
out.flush();
} int n=Integer.parseInt(line); n Integer.parseInt(line) Integer.parseInt Integer line int[] a=new int[n]; a new int[n] n StringTokenizer st=new StringTokenizer(br.readLine()); st new StringTokenizer(br.readLine()) for(int i=0;i<n;i++) a[i]=Integer.parseInt(st.nextToken()); int i=0; int i=0; i 0 i<n i n i++ i++ i a[i]=Integer.parseInt(st.nextToken()); a[i]=Integer.parseInt(st.nextToken()) a[i] a i Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st SelectionSort(a) SelectionSort a getValue(a) getValue a out.println(ans) out.println out ans out.flush() out.flush out String[] args args private static void swap(int[] a,int s,int t){
int tmp=a[s]; a[s]=a[t]; a[t]=tmp; ans++;
} swap {
int tmp=a[s]; a[s]=a[t]; a[t]=tmp; ans++;
} int tmp=a[s]; tmp a[s] a s a[s]=a[t] a[s] a s a[t] a t a[t]=tmp a[t] a t tmp ans++ ans int[] a a int s s int t t private static void SelectionSort(int[] a){
for(int i=0;i<a.length-1;i++){
int min=i;
for(int j=i+1;j<a.length;j++){
if(a[j]<a[min]) min=j;
}
if(i!=min) swap(a,i,min);
}
} SelectionSort {
for(int i=0;i<a.length-1;i++){
int min=i;
for(int j=i+1;j<a.length;j++){
if(a[j]<a[min]) min=j;
}
if(i!=min) swap(a,i,min);
}
} for(int i=0;i<a.length-1;i++){
int min=i;
for(int j=i+1;j<a.length;j++){
if(a[j]<a[min]) min=j;
}
if(i!=min) swap(a,i,min);
} int i=0; int i=0; i 0 i<a.length-1 i a.length-1 a.length a a.length 1 i++ i++ i {
int min=i;
for(int j=i+1;j<a.length;j++){
if(a[j]<a[min]) min=j;
}
if(i!=min) swap(a,i,min);
} {
int min=i;
for(int j=i+1;j<a.length;j++){
if(a[j]<a[min]) min=j;
}
if(i!=min) swap(a,i,min);
} int min=i; min i for(int j=i+1;j<a.length;j++){
if(a[j]<a[min]) min=j;
} int j=i+1; int j=i+1; j i+1 i 1 j<a.length j a.length a a.length j++ j++ j {
if(a[j]<a[min]) min=j;
} {
if(a[j]<a[min]) min=j;
} if(a[j]<a[min]) min=j; a[j]<a[min] a[j] a j a[min] a min min=j min j if(i!=min) swap(a,i,min); i!=min i min swap(a,i,min) swap a i min int[] a a private static void getValue(int[] a){
for(int i=0;i<a.length-1;i++) out.print(a[i]+" ");
out.println(a[a.length-1]);
} getValue {
for(int i=0;i<a.length-1;i++) out.print(a[i]+" ");
out.println(a[a.length-1]);
} for(int i=0;i<a.length-1;i++) out.print(a[i]+" "); int i=0; int i=0; i 0 i<a.length-1 i a.length-1 a.length a a.length 1 i++ i++ i out.print(a[i]+" "); out.print(a[i]+" ") out.print out a[i]+" " a[i] a i " " out.println(a[a.length-1]) out.println out a[a.length-1] a a.length-1 a.length a a.length 1 int[] a a
import java.io.*;
import java.util.StringTokenizer;
  
class Main{
  
static final PrintWriter out=new PrintWriter(System.out);
static int ans=0;
  
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line);
int[] a=new int[n];
StringTokenizer st=new StringTokenizer(br.readLine());
for(int i=0;i<n;i++) a[i]=Integer.parseInt(st.nextToken());
SelectionSort(a);
getValue(a);
out.println(ans);
out.flush();
}
}
  
private static void swap(int[] a,int s,int t){
int tmp=a[s]; a[s]=a[t]; a[t]=tmp; ans++;
}
  
private static void SelectionSort(int[] a){
for(int i=0;i<a.length-1;i++){
int min=i;
for(int j=i+1;j<a.length;j++){
if(a[j]<a[min]) min=j;
}
if(i!=min) swap(a,i,min);
}
}
  
private static void getValue(int[] a){
for(int i=0;i<a.length-1;i++) out.print(a[i]+" ");
out.println(a[a.length-1]);
}
}