#include<bits/stdc++.h>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define pd(a,n) for(int i=0;i<n;i++)cout<<a[i]<<((i==n-1)?"\n":" ");cout<<endl;
#define pdd(a,n,m)for(int i=0;i<n;i++){for(int j=0;j<m;j++)cout<<a[i][j]<<" ";cout<<endl;}
#define mp make_pair
#define pb push_back
#define ll long long
#define int ll
//#define __int64 lng long
#define P pair<int,int>
#define PP pair<P,int>

int k;
int ans;

int lcm(int a,int b){
  if(b==0)
    return a;
    return lcm(b,a%b);
}
int gcd(int a,int b){
  return a*b/lcm(a,b);
}

signed main(){
  cin>>k;
  rep(i,k){
    rep(j,k){
      rep(l,k){
        ans+=lcm(lcm(i+1,j+1),l+1);
      }
    }
  }

  cout<<ans<<endl;
  return 0;
}