nice BTW 
Lol Should Have really Made the RGB in order not the color XD
SCAR Code:
program New;
procedure DeleteColorItem(var ColorData : TIntegerArray; Index : Integer);
var
i : integer;
begin
if (InRange(Index, 0, GetArrayLength(ColorData)-1)) then
begin
for i := index to GetArrayLength(ColorData)-2 do
ColorData[i] := ColorData[i + 1];
SetArrayLength(ColorData, GetArrayLength(ColorData)-1);
end;
end;
procedure DeleteColorValue(var ColorData : TIntegerArray; Value : Integer);
var
i, Length : integer;
begin
Length := GetArrayLength(ColorData);
for i := 0 to Length-1 do
begin
if (ColorData[i] = Value) then
begin
DeleteColorItem(ColorData, i);
Exit;
end;
end;
end;
function OrganizeColors(DataColor : TIntegerArray) : TIntegerArray;
var
i : integer;
begin
for i := 0 to GetArrayLength(DataColor)-1 do
begin
SetArrayLength(Result, GetArrayLength(Result)+1);
Result[GetArrayLength(Result)-1] := AMax(DataColor);
DeleteColorValue(DataColor, Result[GetArrayLength(Result)-1]);
end;
end;
// Finds The Middle 1, 2, 3*, 4, 5
function AMid(Data: TIntegerArray) : Integer;
var
n : TIntegerArray;
begin
n := OrganizeColors(Data);
Result := n[GetArrayLength(n)-1];
end;
function AMin(Data : TIntegerArray) : Integer;
var
Min, i : integer;
begin
if (GetArrayLength(Data) = 0) then Exit;
Min := Data[0];
for i := 0 to GetArrayLength(Data)-1 do
if (Data[i] < Min) then
Min := Data[i];
Result := Min;
end;
var
T : TIntegerArray;
Min, Mid, Max : Integer;
R, G, B : array [1..3] of Integer;
begin
SetArrayLength(T, 5);
T[0] := 10; // Colors
T[1] := 20;
T[2] := 30;
T[3] := 40;
T[4] := 50;
Min := AMin(T);
Mid := AMid(T);
Max := AMax(T);
ColortoRGB(Min, R[1], G[1], B[1]);
ColortoRGB(Mid, R[2], G[2], B[2]);
ColortoRGB(Max, R[3], G[3], B[3]);
writeln('Min Color : R:' + Inttostr(R[1]) + ' B:' + Inttostr(B[1]) + ' G:' + Inttostr(G[1]));
writeln('Mid Color : R:' + Inttostr(R[2]) + ' B:' + Inttostr(B[2]) + ' G:' + Inttostr(G[2]));
writeln('Max Color : R:' + Inttostr(R[3]) + ' B:' + Inttostr(B[3]) + ' G:' + Inttostr(G[3]));
// Writeln('Middle Color = ' + IntToStr(GetMiddle(T)));
end.