"use strict";

// 最大公約数その2（多入力対応）
const getGcd = array => {
  let len, a, b;
	
  len = array.length;
	a   = array[0];
	
  for (let i=1; i<len; i++) {
		b = array[i];
		a = gcdTwoNumbers(a, b);
	}

	return a;
}

function gcdTwoNumbers(x, y) {
  x = Math.abs(x);
  y = Math.abs(y);
  while(y) {
    let t = y;
    y = x % y;
    x = t;
  }
  return x;
}

//　組み合わせ 被りなし
const combineWithoutRepetitions = (comboOptions, comboLength) => {
  if (comboLength === 1) {
    return comboOptions.map(comboOption => [comboOption]);
  }

  // Init combinations array.
  const combos = [];

  // Eliminate characters one by one and concatenate them to
  // combinations of smaller lengths.
  comboOptions.forEach((currentOption, optionIndex) => {
    const smallerCombos = combineWithoutRepetitions(
      comboOptions.slice(optionIndex + 1),
      comboLength - 1
    );

    smallerCombos.forEach((smallerCombo) => {
      combos.push([currentOption].concat(smallerCombo));
    });
  });

  return combos;
}

const main = arg => {
    arg = arg.trim().split("\n");
    const K = parseInt(arg[0].split(" ")[0]);
    
    let answer = 0;
    let A = [];
    
    for(let i=1; i<=K; i++) {
        A.push(i);
    }
    
    // 1種類の時
    for(let i=1; i<=K; i++) {
        answer += i;
    }
    
    // console.log("answer:" + answer)
    
    // 2種類の時
    const combos2 = combineWithoutRepetitions(A, 2);
    const N2 = combos2.length;
    
    for(let i=0; i<N2; i++) {
        answer += gcdTwoNumbers(combos2[i][0], combos2[i][1]) * 6;
    }
    
    // console.log("answer:" + answer)
    
    // 3種類の時
    const combos3 = combineWithoutRepetitions(A, 3);
    const N3 = combos3.length;
    
    for(let i=0; i<N3; i++) {
        answer += getGcd(combos3[i]) * 6;
    }
    
    // console.log("answer:" + answer)
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));