s = list(map(int, input().split()))
k = int(input())
s.sort()
print(s)
if s:
m = 0 # 统计找到的不存在的数的个数
res = 0 # 累值
t = 1 # 当前数
i = 0 # 列表中当前下标
while True:
if i < len(s) and s[i] == t: # 如果当前数存在
i += 1
else: # 当前数不存在
res = (res + t) % 1000000007 # 累值
m += 1
t += 1 # 当前数加一
if m == k: # 找到了k个不存在的数
break
else:
res = sum(range(k + 1)) % 1000000007
print(res)