Magnitude of Power Spectral Density with Different Sampling Frequency
The issue (beside the scaling) here is that your selected frequencies do not align with your FFT grid and that the energy of each complex exponential is smeared out over multiple FFT bins. Your frequency resolution is given by sample rate divide by FFT length. In your case that's 3.906 Hz. Only for frequencies that are an integer multiple of this will all energy fall into a single FFT bin. An easy way to achieve this is to bump the sample rate up to 1024 Hz. Then your frequency resolution is exactly 4 Hz and all your frequencies are an integer multiple of that. Once you fix the scaling as well, it works fine like this:

N=256;
x0=zeros(N,1);
fs=1024; % Fix 1: get to exactly 4Hz frequency resolution
idx = (0:(N-1))'; % Indices
f=20*[1 2 3 4];
A=[1 2 3 4];
K=4;
for ii=1:K
    x0=x0+A(ii)*exp(sqrt(-1)*2*pi*f(ii)*idx/fs);
end
X=fft(x0);

figure;
plot(abs(X)/N); % Fix 2: absolute value only, rescaled