we can construct a min heap of both the files and compair both the min element and using we can add the sum of both the minimum elements , bu using this processes ve can do this work in nlogn time.
Time taken-
1) construct a min heap=o(n) time
2) take 2 min element =o(logn) time
and add them insert into the array (this process will be repeated n-1 times)
insert o(logn)(this will repeat n-1 times)
so total time taken will be o(nlogn)