"On the way, as you came out of Egypt" (Deuteronomy 25:17). Rabbi Levi said: He came upon you from the road like a bandit. This is like a king who had a vineyard, and he surrounded it with a fence and set within it a biting dog. The king said: Whoever comes and breaches the fence, let the dog bite him. The king's own son came and breached the fence, and the dog bit him. And whenever the king wished to call to mind the sin of his son — what he had done within the vineyard — he would say to him, "Remember how the dog bit you." So too, whenever the Holy One, blessed be He, wishes to call to mind the sin of Israel — what they did at Rephidim when they said, "Is the LORD among us or not?" (Exodus 17:7) — He says to them, "Remember what Amalek did to you" (Deuteronomy 25:17).
On the Way as You Came Out of Egypt
Pesikta DeRav Kahana 3:9
[ט] בדרך בצאתכם ממצרים (דברים כה:יז). א"ר לוי מן הדרך בא עליכם כליסטים. למלך שהיה לו כרם והיקיפו גדר והושיב בו המלך כלב נושכן. א' המלך כל מי שיבוא ויפרוץ את הגדר ישכנו הכלב, ובא בנו של מלך ופרץ את הגדר ונשכו הכלב, וכל זמן שהיה המלך מבקש להזכיר חטיא של בנו מה שעשה בתוך הכרם הוא או' לו זכור את שנשכך הכלב. כך כל זמן שהקב"ה מבקש להזכיר חטיין של ישר' מה שעשו ברפידים שאמרו היש י"י בקרבינו אם אין (שמות יז:ז), הוא אומ' להם זכור את אשר עשה לך עמלק (דברים כה:יז).