import java.util.Arrays;
import java.util.Scanner;
public class P2217 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(), a[] = new int[n], max = 0;
for(int i = 0; i < n; i ++) a[i] = sc.nextInt();
Arrays.sort(a);
for(int i = a.length - 1; i >= 0; i--) {
max = Math.max(max, a[i] * (a.length - i));
}
System.out.println(max);
sc.close();
}
}