import java.util.Scanner;
public class _380 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int arr[] = { 1, 8, 6, 2, 5, 4, 8, 3, 7 };
int l = 0;
int r = arr.length - 1;
int max = 0;
while (l < r) {
max = arr[l] < arr[r] ?
Math.max(max, (r - l) * arr[l++]) :
Math.max(max, (r - l) * arr[r--]);
}
System.out.println(max);
}
}