Mirror energy difference and the structure of loosely bound proton-rich nuclei around A=20