Template:
int j = 0; for (int i = 0; i < n; i++) { while (j < n && condition) { increasingProcess; j++; } decreasingProcess; }