It is very important to understand whether this condition is permanent or temporary for you. Temporary sad moods are common to everyone. But if such thoughts are everyday for you, interfere with the quality of life and cause a large amount of inconvenience, then you should seek help from a psychologist or psychotherapist to discuss what worries you so much. The main thing is not to be afraid. After all, the most important thing is to solve the problem, right?
You just need to get rid of the thought that you are of any value. Chuck Palahniuk talked about this in his book "Fight Club".