  We consider the problem of characterizing all functions $f$ defined on the
set of integers modulo $n$ with the property that an average of some $n$th
roots of unity determined by $f$ is always an algebraic integer. Examples of
such functions with this property are linear functions. We show that, when $n$
is a prime number, the converse also holds. That is, any function with this
property is representable by a linear polynomial. Finally, we give an
application of the main result to the problem of determining self perfect
isometries for the cyclic group of prime order $p$.
