#include <stdio.h>
#include <string.h>
char *high(char *a, char *b) {
if (strlen(a) != strlen(b)) {
int i = 0;
for (i = 0; i < (strlen(a) > strlen(b) ? strlen(b) : strlen(a)); i++) {
if (a[i] > b[i]) {
return a;
} else if (a[i] < b[i]) {
return b;
}
}
char *temp1 = strlen(a) > strlen(b) ? a : b;
char *temp2 = strlen(a) > strlen(b) ? b : a;
return temp1[i+1] > a[0] ? temp1 : temp2;
} else {
char *temp = a;
for (int i = 0; i < (strlen(a) > strlen(b) ? strlen(b) : strlen(a)); i++) {
if (a[i] > b[i]) {
temp = a;
break;
} else if (a[i] < b[i]) {
temp = b;
break;
}
}
return temp;
}
}
int judge(char *a, char *b) {
int flag = 1;
if ((int)high(a, b) == (int)a) {
flag = 0;
}
return flag;
}
int main() {
int n = 0;
scanf("%d", &n);
if (n != 0) {
char a[20][10] = {0};
for (int i = 0; i < n; i++) {
scanf("%s", a[i]);
}
char result[200] = {0};
for (int i = 0; i < n; i++) {
for (int j = 0; j < n - 1 - i; j++) {
if (judge(a[j], a[j+1])) {
char temp[10] = {0};
strcpy(temp, a[j]);
strcpy(a[j], a[j+1]);
strcpy(a[j+1], temp);
}
}
}
for (int i = 0; i < n; i++) {
strcat(result, a[i]);
}
printf("%s\n", result);
} else {
printf("%d", 0);
}
return 0;
}