This algorithm finds A in log(n) time
Solved problem 375