Berachos9: 4
הַנִּכְנָס לַכְּרַךְ — מִתְפַּלֵּל שְׁתַּיִם, אַחַת בִּכְנִיסָתוֹ וְאַחַת בִּיצִיאָתוֹ. בֶּן עַזַּאי אוֹמֵר: אַרְבַּע, שְׁתַּיִם בִּכְנִיסָתוֹ וּשְׁתַּיִם בִּיצִיאָתוֹ; וְנוֹתֵן הוֹדָאָה לְשֶׁעָבַר, וְצוֹעֵק לֶעָתִיד לָבֹא:
One who enters a city should pray twice, once upon his entry and once upon his depar-ture. Ben Azzai says: [He should pray] four [times], twice upon his entry and twice upon his departure. He should give thanks for the past, and pray for what will come in the fu-ture.