function Departure();

global MatrixIn;
global numdev ValueCount
global NextDepart NextArrive Devices numfinished Queue
global systime

systime = min(NextDepart);

numfinished = numfinished + 1;

for i =1:numdev
    if NextDepart(i) == min(NextDepart)
        point = i;
    end;
end;

Wrap;

    Devices(point) = 0;
    NextDepart(point) = 10^20;
    
if Queue(1) ~= 0 
    
    Devices(point) = Queue(1);
    NextDepart(point) = systime + MatrixIn(3,Queue(1));
    
    for i = 1:length(Queue)-1
        Queue(i) = Queue (i+1);
    end;
    Queue(length(Queue)) = 0;

end;
