import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

int g(int x) {
    for (int i = 10; ; i *= 10) {
        if (x < i) return i;
    }
}

int f(int x, int y) {
    return x * g(y) + y;
}

void main() {
    int n; readf("%d\n", &n);
    int[] xs = new int[n];
    foreach (i; 0 .. n) {
        readf("%d\n", &xs[i]);
    }
    xs = xs.sort.uniq.array;
    int m[3] = [int.max, int.max, int.max];
    foreach (i; 0 .. n) {
        foreach (j; 0 .. n) {
            if (i == j) continue;
            foreach (k; 0 .. 3) {
                int x = f(xs[i], xs[j]);
                if (m[k] >= x) {
                    int s = x, t;
                    foreach (l; k .. 3) {
                        t = m[l];
                        m[l] = s;
                        s = t;
                    }
                    break;
                }
            }
        }
    }
    m[2].writeln;
}