Array-leader solution (not 100% tested there maybe edge case that may break it)