n,m,p = map(int,input().split()) a = list(map(int,input().split())) m_a = max(a) s = 0 for x in a: s = max(s, x%p) if s == 0: if m_a > m: print(1) else: print(-1) else: ans = 1 x = 1 while x*m_a <= m: x *= s ans += 1 print(ans)