All perfect praise be to Allaah, the Lord of the worlds. I testify that there is none worthy of worship except Allaah and that Muhammad, sallallaahu ‘alayhi wa sallam, is His slave and Messenger.
According to many of the scholars, for one to meet the obligation of spending the night at Mina, he should spend the greater part of the night there. Being so, if you left Mina after midnight, nothing is due on you. You could know that by counting the duration between sunset and the break of dawn, and when half this duration has elapsed, that is midnight. However, if you left Mina before midnight, then, according to the sounder opinion in the sight of Shaafi‘i scholars, you have done wrong and it is due on each one of you to give a mudd (0.75 liter) of foodstuff in charity. According to the opinion reported from Imam Ahmad you can also give an unidentified quantity of food.
Allaah Knows best.