Role of hairpin formation in telomeric quadruplex folding