import java.io.*; import java.util.*; public class Main_yukicoder851 { private static Scanner sc; private static Printer pr; private static void solve() { int n = Integer.parseInt(sc.nextLine()); String aa = sc.nextLine(); String[] aaa = aa.split(" "); if (aaa.length > 1) { pr.println("\"assert\""); return; } long[] a = new long[n]; a[0] = Long.parseLong(aaa[0]); for (int i = 1; i < n; i++) { a[i] = sc.nextLong(); } Arrays.sort(a); long tmp = Math.max(a[0] + a[2], a[0] + a[1]); if (tmp == a[1] + a[2]) { tmp = a[0] + a[1]; } pr.println(tmp); } // --------------------------------------------------- public static void main(String[] args) { sc = new Scanner(System.in); pr = new Printer(System.out); solve(); pr.close(); sc.close(); } static class Printer extends PrintWriter { Printer(OutputStream out) { super(out); } void printInts(int... a) { StringBuilder sb = new StringBuilder(32); for (int i = 0, size = a.length; i < size; i++) { if (i > 0) { sb.append(' '); } sb.append(a[i]); } println(sb); } void printLongs(long... a) { StringBuilder sb = new StringBuilder(64); for (int i = 0, size = a.length; i < size; i++) { if (i > 0) { sb.append(' '); } sb.append(a[i]); } println(sb); } void printStrings(String... a) { StringBuilder sb = new StringBuilder(32); for (int i = 0, size = a.length; i < size; i++) { if (i > 0) { sb.append(' '); } sb.append(a[i]); } println(sb); } } }