For Question2, I think answer should be B. (seconds)
Reason:
Let's take with example of 4 elements {1, 5, 3, 6}
all possible pairs if reps are allowed will be: {1,1}, {1,5}, {1,3}, {1,6}, {5,1},{5,5},{5,3},{5,6}, {3,1}, {3,5}, {3,3}, {3,6}, {6,1}, {6,5}, {6,3}, {6,6}
so, each element will be summed 2N times.
Hence, the sum of all possible pairs can be calculated in a single for loop i.e for(i=0 to N-1) sum+=2N*A[i];
And even if reps are not allowed then also, sum can be done in O(N) time. not O(N^2)
{1,5}, {1,3}, {1,6}, {5,3},{5,6}, {3,6}. here calculation will be sum+=(N-1)*A[i]