Computes the best efficient substitute order of magic square