Middle-age men can only count up to $5$,so they choose a number between $1$ and $5$. Since they have a $50%$ chance of surviving, we deduce that the devil guessed a number between $1$ and $5$ half the times, and a number greater of $5$ the other times.
Every robot is asked the same question of his previous peasant, meaning that the devil guessed the same number for the robot and the middle-age man.
An intelligent robot uses dichotomic researchwould use a binary search algorithm to identify the number, starting from $16$ or $17$. After one wrong attempt, they try $8$ or $9$ or $24$ or $25$ (depending on what the devil answered). After a second wrong attempt, they try $4$, $12$, $20$ or $29$, and so on, until they find the number. Since the robots have always failed to identify the number with the first two steps, we deduce that the devil never guessed $8$, $9$, $16$,$17$, $24$, $25$.
Among the remainings, we can't know which ones he chose, he could have chosen just one or all.
If only one, we get the the minimum sum, which is $1+2+3+4+5+6+7=28$
If all, we get the maximum sum (all the numbers except the excluded ones), which is $429$