let str;
// 值为index*3-1
while(str = parseInt(readline())){
  let sum = 0;
  for(let i = 1;i<=str;i++){
    sum += i*3-1

  }
   console.log(sum)
}