#include #include #include using namespace std; struct a_t { int x, y; }; 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; } bool cmp(const a_t& lhs, const a_t& rhs) { if(lhs.y!=rhs.y) return lhs.y a; while(scanf("%d", &n)==1) { a.resize(n); for(i=0;i