#include<iostream>
using namespace std;
int main()
{
long long int n;
while( cin >> n ) cout << ( 3 * n * n + 6 * n + 3 ) / 2 - 9 << endl;
return 0;
}