#include <iostream>
#include <stdlib.h>

using namespace std;

int main() {
	int n, *nums,tmp,counter = 0;
	cin >> n;

	nums = (int *)malloc(sizeof(int) * n);
	for (int i = 0; i < n; i++)
	{
		cin >> nums[i];
	}

	for (int i = 0; i < n - 1; i++)
	{
		for (int j = n - 1; j >= 1 ; j--)
		{
			
			if (nums[j] < nums[j-1]) {
				tmp = nums[j];
				nums[j] = nums[j-1];
				nums[j-1] = tmp;
				counter++;
			}
		}
	}
	
	for (int i = 0; i < n; i++)
	{
		cout << nums[i];
		if (i == n - 1) cout << endl;
		else cout << " ";
	}

	cout << counter << endl;
	return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
  ll n,num[3];
  cin>>n;
  for(int i=0;i<n;i++) cin>>num[i];
  if(n==2) num[2]=num[1];
  ll d=__gcd(num[0],num[1]);
  d=__gcd(d,num[2]);

  for(int i=1;i<=d;i++)if(d%i==0) cout <<i<<endl;  

  return 0;
}