If the sum is equal to 20 15, the median is 403.
If the sum is equal to 2005, the median is 40 1.
But these two numbers can't be at the end.
The leftmost number is a multiple of 18+1
The rightmost number is a multiple of 18-1
Test: 403 = 18*22+7 is ok; 40 1 = 18*22+5 is.