1 #include<stdio.h>
2 #include<iostream>
3 #include<string>
4 #include<sstream>
5 #define N 100
6 using namespace std;
7 string ts(int n)
8 {
9 ostringstream stream;
10 stream<<n; //n爲int類型
11 return stream.str();
12 }
13 bool cmp(string s1,string s2)
14 {
15 string str1=s1+s2;
16 string str2=s2+s1;
17 if(str1>str2)
18 return 1;
19 else
20 return 0;
21 }
22 int main()
23 {
24 int n;
25 int a[N];
26 while(scanf("%d",&n)!=EOF)
27 {
28 string s="";
29 for(int i=0;i<n;i++)
30 {
31 scanf("%d",&a[i]);
32 }
33 for(int i=0;i<n;i++)
34 {
35 for(int j=0;j<n-i-1;j++)
36 {
37 if(cmp(ts(a[j]),ts(a[j+1])))
38 {
39 int temp=a[j+1];
40 a[j+1]=a[j];
41 a[j]=temp;
42 }
43 }
44 }
45 for(int i=n-1;i>=0;i--)
46 {
47 s+=ts(a[i]);
48 }
49 cout<<s<<endl;
50 }
51 return 0;
52 }