  We present two new quantum algorithms. Our first algorithm is a
generalization of amplitude amplification to the case when parts of the quantum
algorithm that is being amplified stop at different times.
  Our second algorithm uses the first algorithm to improve the running time of
Harrow et al. algorithm for solving systems of linear equations from O(kappa^2
log N) to O(kappa log^3 kappa log N) where \kappa is the condition number of
the system of equations.
