in 865 in East Anglia. After conquering that kingdom, the army proceeded to capture the city of York (Jorvik) and establish the kingdom of Jorvik. The Danes went on to subjugate the kingdom of Northumbria and to take all but the western portion of Mercia. The remaining kingdom of Wessex was the only kingdom of the Heptarchy left. Alfred the Great managed to maintain his kingdom of Wessex and push back the Viking incursions, relieving the neighbouring kingdoms from the threat of the Danes following his famous victory over them at the Battle of Ethandun in 878. Alfred re-established Anglo-Saxon rule over the western half of Mercia, and the Danelaw was established which separated Mercia into halves, the eastern half remaining under the control of the Danes. Ireland was also affected by the Viking expansion across the North Sea. Extensive raids were carried out all along the coast and eventually, permanent settlements were established, such as that of Dublin in 841. Particular targets for these raids were the monasteries on the western coast of Ireland, as they provided a rich source for loot. On such raids the Vikings set up impermanent camps, which were called longphorts by the Irish—this period of Viking raids on the coasts of Ireland has been named the longphort phase after these types of settlements. Ireland in the 9th century was organised into an amalgam of small kingdoms, called tuatha. These kingdoms were sometimes grouped together and ruled by a single, provincial ruler. If such a ruler could establish and maintain authority over a portion of these tuatha, he was sometimes granted the title of High King. Scotland also experienced significant Viking incursions during the 9th century. The Vikings established themselves in coastal regions, usually in northern Scotland, and in the northern islands such as Orkney and Shetland. The Viking invasion and settlement in Scotland provided a contributing factor in the collapse of the kingdoms of the Picts, who inhabited most of Scotland at the time. Not only were the Pictish realms either destroyed or severely weakened, the Viking invasion and settlements may have been the reason for the movement of Kenneth MacAlpin, the king of Dál Riata at that time. The kingdom of Dál Riata was located on the western coast of Scotland, and Viking incursions destroyed it after the death of its previous king, Áed mac Boanta in 839, according to the Annals of