Well I did it pretty dirty, not trying to simplify my solution (I'm skeptic of "k * n/k = n" given that this "n / k" is really "floor (n / k)" ... does this really work for you ?), this gave me :
import Control.Monad (replicateM_)
main = do
t <- readLn
replicateM_ t (readLn >>= print . pe1 . subtract 1)
pe1 n = ( (3 + m3 * 3) * m3 + (5 + m5 * 5) * m5 - (15 + m15 * 15) * m15 ) `quot` 2
where
m3 = n `quot` 3
m5 = n `quot` 5
m15 = n `quot` 15