Implemented algorithmic task #1