#include <stdio.h>
#include <math.h>

	int mod=1000000007;
int fanc(long long a,int n){
return n?(fanc((a*a)%mod,n/2)*(n%2?a:1))%mod:1;
}
int main(void){
	int a,b,N=3,K,count;
	long long sum;
	long long del[100001];
	sum = 0;
	scanf("%d",&K);
	for(a=N;0<a;a--){
		count=N/a;
		del[a]=fanc(count,K);
		if(1<count)
			for(b=2;b<=count;b++)
				del[a]=(del[a]+mod-del[a*b])%mod;
        	sum=(sum+a*del[a])%mod;
 }
    printf ("%lld",sum);
    return 0;
}