24. Let $S$ be any nonempty set of $k$ integers. Find the smallest value of $k$ for which there always exist two distinct integers $x$ and $y$ in $S$ such that $x+y$ or $x-y$ is divisible by 2007 .
24. Ans: 1005
Partition all the possible remainders when divided by 2006 as follows:
$$
(0),(1,2006),(2,3005), \ldots,(1003,1004) .
$$

Suppose $S$ has 1005 elements. If $S$ has two elements with their difference divisible by 2007, we are done. Otherwise the elements of $S$ have distinct remainders when divided by 2007. By the pigeonhole principle, $S$ has two integers whose sum is divisible by 2007. The set $\{1,2, \ldots, 1004\}$ does not have 2 elements, $x, y$ such that $x+y$ or $x-y$ is divisible by 2007 .