An Explicit Formula and its Application to the Selberg Trace Formula