If you have an even number of numbers, there is no middle number. You have to divide the set into two halves, then add the last number in the first half plus the first number in the second half and divide by two to get the median of the set.

1, 7, 12

7 is the middle number, so it is the median

1, 7, 12, 23

No middle number, so:

(7+12)/2=9.5

The median is 9.5

Remember that arrays start with 0, not 1

If you are checking a list of 100 numbers (Array(0)-Array(99)), the median is the average of the 50th and 51st numbers, or (Array(49)+Array(50))/2

If you have an odd number of numbers, then it's the middle number.

If you have 101 numbers (Array(0)-array(100)), the median is the 51st number (101+1)/2, or Array(50)