Roth IRA excess contribution

In reviewing my past Roth contributions, I recently noticed that in 2017 and 2019 I over contributed by $2K each year.  What are my options for these extra funds and will I be penalized for the gains or just the 6% of the excess annually? What do I need to submit in my taxes this year to show the correction? I am over the income limit to contribute in 2024. Thank you.