Determine the maximum value of a (base ten) positive integer N (with non leading zeroes) such that each of the digits of N, with the exception of the first digit and the last digit, is less than the arithmetic mean of the two neighboring digits.
Note: Try to solve this problem analytically, although computer program/ spreadsheet solutions are welcome.