Algorithm of Max