Dipolar magnetic anisotropy energy of laterally confined ultrathin ferromagnets: multiplicative separation of discrete and continuum contributions