Linear time solution for sumArray toy problem