A complex of modules and its applications to local cohomology and extension functors