You seem to be using an older version of Nim which has as a default the
identity hash function (hash(x) = x) which leads, in this case, to poor
performance. Just add this code (after your imports and before `sumA`):
import hashes, bitops
proc hash*(x: int): Hash {.inline.} =
Hash(rotateLeftBits(uint64(x) * 15241094284759029579'u64, 27))
Run
Alternatively, you could update Nim-1.2 or the head of Nim-devel. Also, that
hash is just one that works. There are several other integer hashes available
at: [https://github.com/c-blake/adix](https://github.com/c-blake/adix) in the
file `althash.nim`.