#include #include #include using namespace std; int gcd(int a, int b) { int c; while((c=a%b)) { a=b; b=c; } return b; } int lcm(int a, int b) { return a/gcd(a,b)*b; } int main(void) { int n, i, j, x; int min_lcm, min_idx; vector a; while(scanf("%d", &n)==1) { a.resize(n); for(i=0;ix) { min_lcm=x; min_idx=j; } else if(min_lcm==x && a[min_idx]>a[j]) { min_idx=j; } } swap(a[i+1], a[min_idx]); } for(i=0;i