Notice that a is a root of a^4+a^3+a^2+a+1 = 0
in other words a non real root of a^5-1=0
Lemma: If m is prime to 5, then the numbers m,2m,3m,4m all leave different remainders when divided by 5
Proof: Suppose im and jm both leave the same remainder for 1 \le i,j \le 4; i \ne j, then m(i-j) is divisible by 5.
Since 5 does not divide m, it must divide (i-j). But that is not possible as |i-j| < 5, and 5 cannot divide any number less than it.
That means, m, 2m, 3m and 4m leave remainders 1,2,3,4 in some order.
In other words, if m is not divisible by 5, the numbers,
a^m, a^{2m}, a^{3m}, a^{4m} are equal to a,a^2,a^3, a^4 in some order.
So, 1+a^m + a^{2m} + a^{3m} + a^{4m} = 1 + a+a^2+a^3+a^4 = 0 when m is not divisible by 5
If m is divisible by 5, obviously the expression equals 5.