Counting Derangements of an array of numbers
===

I came across this problem among other interview questions. Given an array of numbers , we have to calculate the total number of derangements that are possible for this array. Derangements of an array are those permuations where no element is in its right place. 
There is no restriction on the kind of numbers in the array.( there could also be dupliates).

I know a solution using the inclusion exclusion principle. I was looking for a recursive formulation , using DP. This approach probably uses memoization and bitmasks. I would be grateful to anyone who can get me started on this. Thanks. 