Consider a set \( \mathcal{S} \) of distinct positive integers such that for every integer \( x \) in \( \mathcal{S} \), the arithmetic mean of the set of values obtained by deleting \( x \) from \( \mathcal{S} \) is an integer. Given that 1 belongs to \( \mathcal{S} \) and that 2002 is the largest element of \( \mathcal{S} \), what is the greatest number of elements that \( \mathcal{S} \) can have? Let's think step by step and output the final answer within \boxed{}.
user