I am sorry to tell you that there is no changeable size for arrays in Codesys V2/V3. The general explanation is that there is no Dynamic Memory Allocation available in a PLC because Dynamic Memory Allocation is considered to be too unreliable.
Your only choice is to define an array with a constant ARRAY[1..N_MAX_SPEED_VALUE] and just use the array until SpeedValue
VAR
arrnValues : ARRAY[1..N_MAX_SPEED_VALUE] OF INT;
END_VAR
VAR CONSTANT
N_MAX_SPEED_VALUE : INT := 100; (*Max Array Size*)
END_VAR
For myself I am really bugged by this limitation. I already requested a feature many times, to define arrays like ARRAY[*], have keywords for start and end and define the actual start and end size when instantiating. This has nothing todo with dynamic memory allocation, because size is defined at compile time.