Let φ(n) be Euler's totient function.
Let f(n)=(∑i=1nφ(ni))mod(n+1).
Let g(n)=∑i=1nf(i).
g(100)=2007.
Find g(5×108).