If you don't know how many data points will be recorded, look into vectors or an external storage device. Alternatively you could use a circular array if you don't mind losing recorded data after a while.
If you know how many data points will be recorded, a basic array will suffice.
As for excluding invalid values:
// Keep trying to get a valid data point
While (RangeInCentimeters > 512 && RangeInCentimeters < 400)
{
delay(1000200); // The minimum value of this delay depends on the sample rate of your sensor
RangeInCentimeters = ultrasonic.MeasureInCentimeters();
}
//... Store data to array/linked list/etc
I changed your max range to 512 because this is likely the max real value (2^9 = 512).