Maximal ideals in preadditive categories and semilocal categories