Investigators were looking Saturday for a motive behind an attack in the German city of Wuerzburg in which a man armed with a long knife killed three people and wounded at least five others.The suspect, a 24-year-old Somali, was shot in the leg by police and arrested after the Friday afternoon attack in the southern city’s downtown area. Police said his life was not in danger and he was being questioned in a hospital.Bavaria’s top security official, Joachim Herrmann, said the suspect had been known to police and had been admitted to a psychiatric unit a few days earlier. He told news agency dpa late Friday that he couldn’t rule out an Islamic extremist motive because one witness had reported hearing the suspect shout “Allahu akbar,” Arabic for “God is great.”The man had lived in Wuerzburg since 2015, most recently in a shelter for the homeless. He apparently did not know the victims. People laid flowers and candles at the scene of the attack.Videos posted on social media showed pedestrians surrounding the attacker and trying to hold him at bay with chairs and sticks.Bavarian governor Markus Soeder praised the “really impressive dedication” of those who tried to stop the man. “Now the circumstances have to be cleared up, the motives,” he said in a statement to reporters in Nuremberg.“All of Bavaria is in mourning today,” said Soeder, who added that he would order flags flown at half-staff in the state.