Sayyiduna Abu Huraira (may Allah be pleased with him) narrates this statement of the Prophet Muhammad (peace and blessings be upon him): "When a person comes to a gathering, he should greet (with salam). Then if he finds it appropriate to sit there, he may sit. And when he stands up (to leave), he should greet (with salam), because the first one is not more entitled than the second."