An example:
$posts_ids = array(2,56,87,23,5); // this is an array of posts IDs
<?php $my_query = new WP_Query(array('post__in'=>$posts_ids)); ?>
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
<!-- Do stuff... -->
<?php endwhile; ?>