public static int CMMNo(int[] dimension){
		int size = dimension.length - 1;
		int[][] array = new int[size][size];
		String[][] sequence = new String[size][size];
		int min;
		int temp;
		for(int i = 0; i < size; i++){
			array[i][i] = 0;
			sequence[i][i] = "" + i;
		}
		for(int i = 0; i < size; i++){
			for(int j = i+1; j < size; j++){
				array[i][j] = Integer.MAX_VALUE;
				sequence[i][j] = "";
			}
		}
		for(int i = 1; i < size; i++){
			for(int j = 0; j+i < size; j++){
				for(int k = j; k < j+i; k++){
					temp = array[j][k] + array[k+1][j+i] + dimension[j] * dimension[k+1] * dimension[j+i+1];
					if (array[j][j+i] > temp){
						array[j][j+i] = temp;
						sequence[j][j+i] = "(" + sequence[j][k] + ")" + "(" + sequence[k+1][j+i] + ")";
					} 
				}
			}
		}
		// for(int i = 0; i < size; i++){
		// 	for(int j = 0; j < size; j++)
		// 		System.out.print(array[i][j] + " ");
		// 	System.out.println();
		// }
		System.out.println(sequence[0][size-1]);
		return array[0][size-1];
	}