Longest Almost Flat Subarray

I have a question in regards to subarrays. In specific I am required to find the longest almost flat contiguous subarray within a given array. It’s defined as almost flat if the elements in the array only differ by 1.
For example if the array given was {7,8,9,9,7,8,8,7,8,8,7} then the longest almost flat subarray would be {7,8,8,7,8,8,7}. I am required to print out the index of where the longest almost flat subarray starts and also how many characters are in it. Any help regarding this problem would be greatly appreciated.