This is a hash table problem.
TotalSet T
N-1 subset can be defined as S(n) n index element dropped sequence, 1<= n <= N.
Then multiply of S(n) can be described as T(1:n-1) * T( n+1 : N)
so we make a hash table for HashTable1(n) save from 1 to n multiply , HashTable2(n), save from N to i multiply
for i in range(1,N+1):
HashTable1.put(i, HashTable1.getOrDefault(i, 1) * i);
for i in range(1,N+1, -1):
HashTable2.put(i, HashTable1.getOrDefault(i, 1) * i);
for i in range(1,N+1):
print(HashTable1.getOrDefault(i, 1 ) * HashTable2.getOrDefault(i , 1 ))