How to re-add deleted articles using the same node ids?
It really depends on the amount of data you have at hand. If the missing nodes have simple structure with only default body field,title, none or just a few custom fields, then 40 is not that big number to sweat over the code, so I would do it via database UI as phpMyAdmin. Just note other involved tables like node_revision and custom field tables if nodes had ones.

However, if the missing nodes have multiple fields and too much data to enter manually, then I would create and upload data to 40 new nodes iterating:

$entity = entity_create('node', $values);
$service_wrapper = entity_metadata_wrapper('node', $entity);
$service_wrapper-&gt;title-&gt;set($product-&gt;title);
$service_wrapper-&gt;field_custom_field_1-&gt;set($data_1);
$service_wrapper-&gt;field_custom_field_2-&gt;set($data_2);
$service_wrapper-&gt;field_custom_field_N-&gt;set($data_N);
$service_wrapper-&gt;save();


Then I would replace nids either manually in nodes and node_revision tables or by saving the missing nids in form of $nids = array(0 =&gt; 'first nid', 1 =&gt; 'second nid, 2 =&gt; '2nd nid', n =&gt; 'so forth') and then iterating them through foreach loop in custom module's function.