וַיְהִי אַבְרָם, בֶּן-תִּשְׁעִים שָׁנָה וְתֵשַׁע שָׁנִים
there was a predicament. The Torah text had (Bereshit 20)וַיִּסַּע מִשָּׁם אַבְרָהָם אַרְצָה הַנֶּגֶב
directly after (Bereshit 16)וְשָׂרַה אֵשֶׁת אַבְרָהָם לֹא יָלְדָה לוֹ
Note the elegance of the Torah Keduma. Bereshit 20 has the same structure as Bereshit 16, in reverse. Where the latter ends, between Kadesh and Bered, the latter starts, between Kadesh and Shur. Bereshit 16 starts with וְשָׂרַה אֵשֶׁת אַבְרָם whereas Bereshit 20 ends with it.What was the problem, P's predicament?
Insertion of וַיְהִי אַבְרָם in between וַיִּסַּע מִשָּׁם and וְשָׂרַה אֵשֶׁת was impossible because Sarah was young in וַיִּסַּע מִשָּׁם and old in וַיְהִי אַבְרָם. Insertion of וַיְהִי אַבְרָם after וַיִּסַּע מִשָּׁם broke the textual connection between the pesukim in which Avraham prays successfully for opening of the wombs in the house of Abimelech, and the opening of Sarah's womb.
Therefore, P had to replace וַיִּסַּע מִשָּׁם by וַיְהִי אַבְרָם. Where, then. should וַיִּסַּע מִשָּׁם be put? The solution: after the announcement that Sarah's womb would be opened (Bereshit 18) and before it actually happened (Bereshit 21), and so we find it as Bereshit 20. The announcement regarding Sarah would imply that Sarah became apparently young again! However, this causes another predicament. It brought the opening of Sarah womb very close to her sojourn in Abimelech's house, too close to be confortable. That is why we find in Bereshit 21:1-3 confirmation after confirmation after confirmation, by P, that Yitzchak was indeed the son of Avraham.