The smallest pair Time limit exceeded?

please help in finding the bug, problem link.


program SMPAIR;

var 
   t,x,N,y,temp:longint;
   num:array[1..100000] of longint;
begin
	read(t);
	
	for x := 1 to t do
	begin
	    readln(N);
	    num[x] := N;
	end;
	
	for x := 1 to t do
	begin
	for y := 1 to t-1 do
	begin
	    if num[y] > num[y+1] then
	    begin
	    temp := num[y];
	    num[y] := num[y+1];
	    num[y+1] := temp;
	    end;
	    
	end;
	end;
	
	
	    writeln(num[1]+num[2]);
end.

is the reason is this that i am not using a fast sorting method?, i think this one is bubble sort and its time complexity is O(n$^2$)?

You need not sort the array, in this question.

Do this…
scan the first element of array… and let it be the smallest.
and let second smallest be 10000001.
then input the number one by one and compare.

n=read();
t=read();
small1=t;
small2=1000001;
for(i=1;i<n;i++)
{
t=read();
if(t<small1)
{
small2=small1;
small1=t;
}
else if(t<small2)
small2=t;
}
printf("%ld\n",small1+small2);

min1:=maxlongint-2; min2:=maxlongint;
for i:=1 to n do
begin
read(x);
if (min1>x) and (min1>min2) then min1:=x
else if (min2>x) and (min2>min1) then min2:=x;
end;
writeln(min1+min2);