public int secondPeakOrFirstIfUnavailable() {
		int fpPtr = 0;
		int best = 0;
		for (int i = 0; i < hg.length; i++) {
			if (hg[i] < best) {
				break;
			} else {
				fpPtr = i;
				best = hg[i];
			}
		}
		
		int vallPtr = fpPtr;
		for (int i = fpPtr; i < hg.length + 1; i++) {
			if (i == hg.length) { return fpPtr + offset; }
			if (hg[i] > best) {
				break;
			} else {
				vallPtr = i;
				best = hg[i];
			}
		}
		
		int spPtr = vallPtr;
		for (int i = vallPtr; i < hg.length + 1; i++) {
			if (i == hg.length) { return fpPtr + offset; }
			if (hg[i] < best) {
				break;
			} else {
				spPtr = i;
				best = hg[i];
			}
		}
		
		return spPtr + offset;
	}