Solution:
Answer: 22011−2012
Let n be the element of A not in the range of f. Let m be the element of A that is hit twice.
We now sum the total number of functions over n,m. Clearly f(1)=1, and by induction, for x≤m, f(x)=x. Also unless n=2011, f(2011)=2011 because f can take no other number to 2011. It follows from backwards induction that for x>n, f(x)=x. Therefore n>m, and there are only n−m values of f that are not fixed.
Now f(m+1)=m or f(m+1)=m+1. For m<k<n, given the selection of f(1),f(2),…,f(k−1), k−1 of the k+1 possible values of f(k+1) (1,2,3,…,k, and counting m twice) have been taken, so there are two distinct values that f(k+1) can take (one of them is k+1, and the other is not, so they are distinct). For f(n), when the other 2010 values of f have been assigned, there is only one missing, so f(n) is determined.
For each integer in [m,n), there are two possible values of f, so there are 2n−m−1 different functions f for a given m,n. So our answer is
m=1∑2010n=m+1∑20112n−m−1=m=1∑20102−m−1n=m+1∑20112n=m=1∑20102−m−1(22012−2m+1)=m=1∑201022011−m−1=(m=1∑20102m)−2010=22011−2012