  A model with nucleons in a charge-independent potential well interacting by
an isovector pairing force is considered. For a 24-dimensional valence space,
the Hartree-Bogolyubov (HB) plus random phase approximation (RPA) to the lowest
eigenvalue of the Hamiltonian is shown to be accurate except near values of the
pairing force coupling constant G where the HB solution shifts from a zero to a
non-zero pair gap. In the limit G -> infinity the HB + RPA is asymptotically
exact. The inaccuracy of the HB + RPA in the critical regions of G can be
remedied by interpolation. The resulting algoritm is used to calculate pairing
corrections in the framework of a Nilsson-Strutinsky calculation of nuclear
masses near N = Z for A = 24-100, where N and Z are the numbers of neutrons and
protons, and A = N + Z. The dimension of the valence space is 2A in these
calculations. Adjusting five liquid drop parameters and a power law expression
for the constant G as a function of A allows us to reproduce the measured
binding energies of 112 doubly even nuclei in this range with a root mean
square deviation of 0.95 MeV. Several combinations of the masses for different
N, Z, and isospin T are considered and the calculations found to be in good
agreement with the data. It is demonstrated by examples how fluctuations as a
function of A of the constant X in an expansion of the symmetry energy of the
form T(T+X)/(2 theta) can be understood from the shell structure.
