Entropy function and higher derivative corrections to entropies in (anti-)de Sitter space