/*
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
char* solution(int numbers[], int numbers_len) {
// return 값은 malloc 등 동적 할당을 사용해주세요. 할당 길이는 상황에 맞게 변경해주세요.
char* answer = (char*)malloc(sizeof(char)*(numbers_len));
float* numbers2 = (float*)malloc(sizeof(float)*numbers_len);
float* numbers3 = (float*)malloc(sizeof(float)*numbers_len);
int* size= (int*)malloc(sizeof(int)*numbers_len);
int i,j,max,x=0,cnt=0;
for(i=0;i<numbers_len;i++){
numbers2[i]=numbers[i];
numbers3[i]=numbers[i];
}
j=0;
for(i=0;i<numbers_len;i++){
while(numbers2[j]>=10){
numbers2[j]/=10;
cnt++;
}
j++;
}
for(i=0;i<numbers_len;i++){
max=0;
for(j=0;j<numbers_len;j++){
if(max<numbers2[j]){
max=numbers2[j];
size[i]=j;
}
}
numbers2[size[i]]=0;
}
for(i=0;i<numbers_len;i++)
{
//printf("%n ",numbers[i]);
}
for(i=0;i<numbers_len+x;i++){
if(numbers[size[i]]<10) answer[i]=numbers[size[i]]+'0';
else if(10<=numbers[size[i]]&&numbers[size[i]]<100){
answer[i]=numbers[size[i]]/10+'0';
i++;
x++;
answer[i]=numbers[size[i-x]]%10+'0';
}
else if(100<=numbers[size[i]]&&numbers[size[i]]<1000){
answer[i]=numbers[size[i]]/100+'0';
i++;
x++;
answer[i]=(numbers[size[i]]/10)%10+'0';
i++;
x++;
answer[i]=(numbers[size[i]]%100)+'0';
}
else{
answer[i]=numbers[size[i]]/1000+'0';
answer[i+1]=(numbers[size[i]]/100)%10+'0';
answer[i+2]=(numbers[size[i]]/10)&100+'0';
answer[i+3]=(numbers[size[i]])%1000+'0';
i+=3;
x+=3;
}
}
return answer;
}
*/
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
// numbers_len은 배열 numbers의 길이입니다.
char* solution(int numbers[], size_t numbers_len) {
// return 값은 malloc 등 동적 할당을 사용해주세요. 할당 길이는 상황에 맞게 변경해주세요.
char* answer;
float* num2=(float*)malloc(sizeof(float)*numbers_len);
int* len2=(int*)malloc(sizeof(int)*numbers_len);
int* len3=(int*)malloc(sizeof(int)*numbers_len);
int i,j=0,k=0,cnt=1,tmp1,tmp2;
for(i=0;i<numbers_len;i++){
num2[i]=numbers[i];
len2[i]=1;
len3[i]=i+1;
while(num2[j]>=10){
num2[j]/=10;
len2[j]++;
cnt++;
//printf("%d ",j);
}
j++;
}
for(i=0;i<numbers_len;i++){
cnt+=len2[i];
}
answer=(char*)calloc(cnt,sizeof(char));
for(i=0;i<=numbers_len;i++){
for(j=0;j<numbers_len-1;j++){
if(num2[j]<num2[j+1]){
tmp1=num2[j];
num2[j]=num2[j+1];
num2[j+1]=tmp1;
tmp2=len3[j];
len3[j]=len3[j+1];
len3[j+1]=tmp2;
}
else if(num2[j]==num2[j+1]&&numbers[j]>numbers[j+1]){
tmp1=num2[j];
num2[j]=num2[j+1];
num2[j+1]=tmp1;
tmp2=len3[j];
len3[j]=len3[j+1];
len3[j+1]=tmp2;
}
}
} for(i=0;i<numbers_len;i++){
printf("%f ",num2[i]);
}
//for(i=0;i<numbers_len;i++){
//printf("%d ",len3[i]-1);
//printf("%d ",len2[len3[i]-1]);
//}
for(i=0;i<numbers_len;i++){
if(len2[len3[i]-1]==1){
answer[k++]=numbers[len3[i]-1]+'0';
}
else if(len2[len3[i]-1]==2){
answer[k++]=numbers[len3[i]-1]/10+'0';
answer[k++]=numbers[len3[i]-1]%10+'0';
}
else if(len2[len3[i]-1]==3){
answer[k++]=numbers[len3[i]-1]/100+'0';
if((numbers[len3[i]-1]%100)!=(numbers[len3[i]-1]%10)) answer[k++]=((numbers[len3[i]-1]%100)-(numbers[len3[i]-1]%10))+'0';
else answer[k++]='0';
answer[k++]=numbers[len3[i]-1]%10+'0';
}
else{
answer[k++]=numbers[len3[i]-1]/1000+'0';
answer[k++]=numbers[len3[i]-1]%1000/100+'0';
answer[k++]=numbers[len3[i]-1]%100/10+'0';
answer[k++]=numbers[len3[i]-1]%10+'0';
}
answer[k]=0;
/*
5
9 909 1 0 10
*/
printf("%s\n",answer);
}
//for(i=0;i<numbers_len+cnt;i++) printf("%c",answer[i]); printf("\n");
return answer;
}
int main()
{
int i;
int numbers[100]={},numbers_len;
scanf("%d",&numbers_len);
for(i=0;i<numbers_len;i++){
scanf("%d",&numbers[i]);
}
printf("%s",solution(numbers,numbers_len));
return 0;
}