function [MA,indexS] = extraampA(MAI,lA)

gamma=zeros(1,length(MAI));
for i=length(MAI):-1:(length(MAI)-lA)    
    gamma(i)=((length(MAI)-i)/lA)*MAI(1,end-lA);
end

MA=MAI-gamma;
indexS=0;

for i=length(MAI):-1:(length(MAI)-lA)
    if MA(i)<=0
        indexS = i;
        break;
        
    end
end
if indexS == 0
    indexS = lA;
end


end