totalEnergy1D_R: Total energy in periodic boundary conditions in 1D
Description
Given a vector of flip sites, 1s or -1s, representing up and down spins
respectively, return total energy, applying periodic boundary
conditions, i.e., cyclic. This function is pure R implementation.