Input Format
The first line consists of an integer, , the size of each group.
The second line contains the unordered elements of the room number list.
Constraints
Output Format
Output the Captain's room number.

hackerrank the captain's room problem solution in python

Problem solution in python 2 programming language.

K = int(raw_input())

#Step 1
roomList = map(int,raw_input().split())

#Step 2
roomSet = set(roomList) 

#Step 3
sumRoomSet = sum(roomSet) 
sumRoomList = sum(roomList) 

# Step 4
temp = sumRoomSet * K - sumRoomList 

# Step 5
answer = temp / (K - 1) 

# Step 6
print answer

Problem solution in python 3 programming language.

K = int(input())
set_S = set()
sumlist_S = 0
for i in input().split():
    I = int(i)
    set_S.add(I)
    sumlist_S += I

print((sum(set_S)*K - sumlist_S)//(K-1))