You attempted to install grub on /dev/md0p1, which is not possible. You must install grub to the underlying physical disk(s), i.e. /dev/sda.
You attempted to install grub on /dev/md0p1, which is not possible. You must install grub to the underlying physical disk(s), i.e. /dev/sda.