smallest sequence problem