Implementation of sum_to_n?(array, n).