Answer: 2n(n−1)/2.
Let N=2n and v2(a)=s if and only if 2s∣a and 2s+1∤a, for a positive integer a. Let v2(A)={v2(a)∣a∈A} for the set A.
Claim: A set A is good if and only if v2(A)={0,1,…,n−1}.
First we show that sets of the form An={2ibi∣bi odd,0≤i≤n−1} are good. For n=1, this is trivial. For n≥1, assume An is good:
{S(X)(modN)∣X⊆An}={0,1,…,N−1}(modN),
and
{S(X)(mod2N)∣X⊆An+1}={S(X),S(X)+N(mod2N)∣X⊆An}.
This implies
{S(X)(mod2N)∣X⊆An+1}={0,1,…,2N−1}(mod2N).
Hence, An+1 is good.
Assume that A={a1,a2,…,an} is good, and M=2N−1. Since 2N≡1(modM) and
{S(X)(modN)∣X⊆A}={0,1,…,N−1}(modN),
we have
j=1∏n(2aj+1)=X⊆A∑2S(X)≡k=0∑N−12k≡0(modM).
Note M=∏i=0n−1(22i+1). Therefore, for any 0≤i≤n−1, there exists 1≤j≤n such that d=gcd(22i+1,2aj+1)=1. Thus 22i≡2aj≡−1(modd), and 22i+1≡22aj≡1(modd), implying 2i+1∣2aj. Since 2s≡1(modd) where s≤i+1, s>i. Therefore, s=i+1, and aj=2ibi, where bi is odd. Thus, {0,1,…,n−1}⊆v2(A), and ∣v2(A)∣=n.
Thus, the number of good sets such that all elements are less than 2n is:
2n−1×2n−2×⋯×20=22n(n−1).