#include <stdio.h>

void swap(int *A1, int *A2) {
	int tmp;
	tmp = *A1;
	*A1 = *A2;
	*A2 = tmp;
}

int  selectionSort(int A[], int N) {
	int i, j, count = 0;
	
	for (i = 0; i < N; i++) {
		for (j = i; j < N; j++) {
			if (A[i] > A[j]) {
				swap(&A[i], &A[j]);
				count++;
			}
		}
	}
	
	return count;
}

int main(void) {
	int N;
	int A[100];
	int i;
	int kai;

	scanf("%d", &N);
	
	for (i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	
	kai = selectionSort(A, N);

	for (i = 0; i < N; i++) {
		if (i > 0) printf(" ");
		printf("%d", A[i]);
	}
	printf("\n");

	printf("%d\n", kai);

	return 0;
}