After a probationary period in the game development company of IT City Petya was included in a group of the programmers that develops a new turn-based strategy game resembling the well known "Heroes of Might & Magic". A part of the game is turn-based fights of big squadrons of enemies on infinite fields where every cell is in form of a hexagon.Some of magic effects are able to affect several field cells at once, cells that are situated not farther than n cells away from the cell in which the effect was applied. The distance between cells is the minimum number of cell border crosses on a path from one cell to another.It is easy to see that the number of cells affected by a magic effect grows rapidly when n increases, so it can adversely affect the game performance. That's why Petya decided to write a program that can, given n, determine the number of cells that should be repainted after effect application, so that game designers can balance scale of the effects and the game performance. Help him to do it. Find the number of hexagons situated not farther than n cells away from a given cell.

The only line of the input contains one integer n (0 ≤ n ≤ 109).

Output one integer — the number of hexagons situated not farther than n cells away from a given cell.

#include<iostream>
using namespace std;
int main()
{
    long long n;
    cin>>n;
    long long sum=1;
    if(n>=1)
    sum+=6*n+((n-1)*n*6)/2;
    cout<<sum<<endl;
    return 0;
}
//2019-11-25 15:03:01.678

#include <bits/stdc++.h>
using namespace std;
int main()
{
    unsigned long long int a,n,s=0;
    cin>>n;
    s=(n*(n+1)/2);
    cout<<(s*6)+1<<endl;
    return 0;
}

#include <iostream>
#include <cmath>
using namespace std;

int main()
{
    int n;
    cin>>n;
    long long sum=1+6*((pow(n,2)+n)/2);
    cout<<sum;
}

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
    unsigned long long ans=0,n;
    scanf("%I64d",&n);
    ans=(1+n)*n*3+1;
    cout<<ans<<endl;
    return 0;
}

#include <iostream>
#include <string>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(){
	ll n;
	cin>>n;
	ll sum=1,r=1;
	sum+=(3*(n+1)*n);
	cout<<sum<<endl;
}

#include <bits/stdc++.h>
#define ull unsigned long long
using namespace std;
int main(){
	ull A,c,i;
	cin>>A;
    c=A*(3*(A+1))+1;
    cout<<c<<endl;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    typedef long long int ll;
    ll n,i,res=0;
    cin>>n;
    if(n==0)
        res++;
    else
    {

        res=(ll)(((float)n/2.0)*(2*6+(n-1)*6));
        res++;
    }
    cout<<res<<endl;
    return 0;
}

#include<iostream>
using namespace std;

int main(){
#pragma warning(disable : 4996)

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	long long int a, n;

	cin >>n;

	a = (3*n*(n + 1)) + 1;

	cout << a;

	return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define clr(a) memset(a, 0, sizeof(a))
#define rep(n) for(int i=0; i<n; i++)
#define repc(i, n) for(int i=0; i<n; i++)
#define rep1(n) for(int i=1; i<=n; i++)
#define repc1(i, n) for(int i=1; i<=n; i++)
#define all(v) v.begin(), v.end()
#define alla(a,n) a, a+n
#define endl "\n"
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vi;
//.............................................................

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    long n;
    cin>>n;
    ll ans = (n-1);
    ans *= 6;
    ans += 12;
    ans *= n;
    ans /= 2;
    ans++;
    cout<<ans;

	return 0;
}

#include <iostream>

using namespace std ;

int main(){
	long long hex, n, m ;
	cin >> n ;
	m = n * (n+1)/2 ;
	hex = m * 6 + 1 ;

	cout << hex << endl ;
	return 0 ;
}

#include <bits/stdc++.h>
using namespace std;
int main ()
{
	long long a;
	cin>>a;
	cout<<(a+1)*3*a+1;
}

#include<stdio.h>
#include<math.h>
/*#include<bits/stdc++.h>
using namespace std;*/
int main()
{
	long long n,t2,t3,t4,t1;
	scanf("%lld",&n);
	t1=n;
	t2=(n-1)*6;
	t3=12+t2;
	t4=(t3*t1)/2;
	printf("%lld",t4+1);
return 0;
}

#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;

#define  Infile         freopen("input.txt", "r", stdin)
#define  Outfile        freopen("output.txt", "w", stdout)
#define  show(a)        cerr<<"\n-> "<<#a<<" = "<<a<<endl
#define  fu(i,a,b)      for(ll i=(a); i<=ll(b);++i)
#define  fd(i,a,b)      for(ll i=(a); i>=ll(b);--i)
#define  fo(i,n)        for(ll i=0; i<ll(n);++i)
#define  grter(u)       u,vector<u>,greater<u>
#define  fixset(x)      fixed<<setprecision(x)
#define  ms(a, x)       memset(a,x,sizeof(a))
#define  all(x)         (x).begin(),(x).end()
#define  mp(a,b)        make_pair(a,b)
#define  pb(x)          push_back(x)
#define  pr(a)          cout<<a<<endl
#define  prs(a)         cout<<a<<" "
#define  ar(x, n)       (x),(x)+(n)
#define  _              <<", "<<
#define  fii            first
#define  see            second
#define  endl           '\n'

typedef double db;
typedef long long ll;
typedef vector <ll> vii;
typedef pair <ll, ll> pll;

clock_t TimeBegin, TimeEnd;
ll LX[] = {-1,0,0,1,-1,-1,1,1}; // 4 - 8
ll LY[] = {0,-1,1,0,-1,1,-1,1};
ll const INF = 1e18;
db const EPS  = DBL_EPSILON;

inline void Tstop();
inline void Tstart();
inline ll eulerPhi(ll NUM);
inline ll mnmize(ll& a,ll b);
inline ll mxmize(ll& a,ll b);
inline ll mod(string NUM, ll BASE);
inline ll fpow(ll Aa, ll Ax, ll BASE);
inline ll diMod(ll Aa, ll Bb, ll BASE);
inline ll mulMod(ll Aa, ll Bb, ll BASE);
inline string toString(ll NUM);

//Declare Here
ll n;

//============//

void Solve()
{
    //code here
    cin >> n;
    cout << (n*(n+1))*3+1;

}

//=============================================================================//

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    #ifdef RAVENCLAW
        Tstart();
        //Infile;
        //Outfile;
    #endif
        Solve();
        Tstop();
    return 0;
}

//=============================================================================//
//=============================================================================//

inline ll mod(string NUM, ll BASE)
{
    ll RES = 0;
    fo(i, NUM.length())
        RES = (RES*10 + (ll)NUM[i] - '0') % BASE;
    return RES;
}

ll fpow(ll Aa, ll Xx, ll BASE)
{
    ll res = 1;
    ll temp = Aa%BASE;
    while(Xx > 0)
    {
        if (Xx&1)
            res = (res*temp)%BASE;
        Xx >>= 1;
        temp = (temp*temp)%BASE;
    }
    return res;
}

inline ll diMod(ll Aa, ll Bb, ll BASE)
{
    //(A/B)%Base
    ll result = (Aa * fpow(Bb, BASE-2, BASE)) % BASE;
    return result;
}

inline ll mulMod(ll Aa, ll Bb, ll BASE)
{
    Aa %= BASE;
    Bb %= BASE;
    ll Qq = ((long double)Bb / BASE)*Aa;
    ll Rr = Aa * Bb - Qq * BASE;
    return (Rr % BASE + BASE) % BASE;
}

inline ll eulerPhi(ll NUM)   // O(sqrt(n))
{
    if (NUM == 0)
        return 0;
    ll RESULT = NUM;
    for (ll TMPX = 2; TMPX*TMPX <= NUM; ++TMPX)
    {
        if (NUM % TMPX == 0)
        {
            RESULT -= RESULT / TMPX;
            while (NUM % TMPX == 0)
                NUM /= TMPX;
        }
    }
    if (NUM > 1) RESULT -= RESULT / NUM;
        return RESULT;
}

inline string toString(ll NUM)
{
    stringstream sss; sss << NUM;
    return sss.str();
}

inline ll mnmize(ll& a,ll b)
{
    return a = (a > b ? b : a);
}

inline ll mxmize(ll& a,ll b)
{
    return a = (a < b ? b : a);
}

inline void Tstart()
{
    TimeBegin = clock();
}

inline void Tstop()
{
    #ifdef RAVENCLAW
    TimeEnd = clock();
    cout << "\nTime elapsed: " << 1000 * (TimeEnd - TimeBegin) / CLOCKS_PER_SEC << " ms\n";
    #endif
}

#include<iostream>

using namespace std;
int main(){
	long long n,sum=1;
	cin>>n;
	cout<<1+(3*n*(n+1));
	}

#include <iostream>
#include <cstdio>
#include <queue>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <cstring>
#include <stack>
#include <algorithm>

using namespace std;

int main() {
	/*freopen("input.txt", "r", stdin);*/
	/*freopen("gcd.in", "r", stdin);
	freopen("gcd.out", "w", stdout);*/
	long long a;
	cin >> a;
	long long sum = 1, a1, a2;
	if (a > 1) {
		a1 = 6, a2 = a1 * a;
		sum += ((a1 + a2) * a) / 2;
	}
	else if (a == 1) sum = 7;
	cout << sum << endl;
}

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
LL ans,sum;
int main()
{
  LL n;
  while(scanf("%lld",&n)!=EOF)
  {
    if(n==0) {printf("1\n");continue;}
    //if(n==1) {printf("7\n");continue;}
    sum=0;ans=0;
    if(n%2==0)
    {
      sum=(1+n)*(n/2);
    }
    else
    {
      sum=(1+n)*(n/2)+(1+n)/2;
    }
    ans=sum*6+1;
    printf("%lld\n",ans);
  }
  return 0;
}

#include <cstdio>

int main(int argc, char const *argv[])
{
    long long n;
    scanf("%I64d", &n);
    printf("%I64d\n", 3*n*(n+1)+1);
    return 0;
}/*2018-08-29 01:10:44.947*/

#include <iostream>
using namespace std;
typedef long long ll;
int main(){
    ll n; cin>>n;
    cout<<3*(n+1)*n +1;

    return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;
typedef unsigned long long ll;

int main() {
	ll n; cin >> n;
	cout << 1 + 6 * n * (n + 1) / 2;

	return 0;
}

#include <iostream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <math.h>
#include <map>
#include <iomanip>
#include <functional>
#include <list>
#include <random>
#include <queue>
#include <stdio.h>
#include <regex>
#include <bitset>
#include <numeric>
#include <assert.h>

using namespace std;

typedef long long int64;
typedef vector<int64> VI;
typedef pair<int64, int64> PII;

#define forn(i, n) for (int64 i = 0; i < int64(n); i++)
#define nfor(i, n) for (int64 i = int64(n) - 1; i >= 0; i--)
#define fore(i, l, r) for (int64 i = int64(l); i < int64(r); i++)
#define all(a) (a).begin(), (a).end()
#define mp(x, y) make_pair((x), (y))
#define sqr(a) ((a) * (a))

const int64 INF = 1e18;
const int64 MOD = 1000000007;

const int64 N = 1e6 + 13;

inline int MID(int l, int r) { return (l + r) / 2; }
inline int LSON(int u) { return u * 2; }
inline int RSON(int u) { return u * 2 + 1; }

long double xD(long double a,int64 pow)
{

	if (pow == 0) return 1;

	if (pow % 2 == 0)
	{
		long double b = xD(a, pow / 2);
		return b*b;
	}
	else
	{
		return xD(a, pow - 1)*a;
	}

}

int main()
{
#ifdef _DEBUG
	freopen("ReadMe.txt", "r", stdin);
	//test();
#endif

	int64 n;
	cin >> n;

	if (n == 0)
	{
		cout << 1; return 0;
	}

	cout << 1LL + 3LL*n*(n+1LL);

	return 0;

}

#include<stdio.h>
#include<string.h>
#include<math.h>
using namespace std;

int main()
{
    __int64 t;
    scanf("%I64d",&t);
    __int64 sum=1;
    __int64 n=1;
   // for(int i=0;i<t;i++)
    {
        n=(1+t)*t*3;
        sum=sum+n;
    }
    if(t==0)printf("1");
    else printf("%I64d",sum);
}

#include<iostream>
#include<cstdio>
#include<set>
#include<map>
#include<vector>
#include<cstring>
#include<string>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<cctype>
#include<cstdlib>
#define mem(x); memset(x,0,sizeof(x));
#define mem2(x); memset(x,-1,sizeof(x));
#define xh(i,k,N) for(i=(k);i<(N);i++)
#define hx(i,k,N) for(i=(k);i>(N);i--)
#define gcd(a,b); {return a==0?b:gcd(b%a,a);}
using namespace std;
const int INF =0x3f3f3f3f;
const double eps = 1e-8;
const double pi = acos(-1.0);
const int MAXN = 100000+10;
typedef long long ll;
typedef unsigned long long llu;
typedef long double ld;
ll T,t=0;
ll i;
int main(void){
	scanf("%d",&T);
		t=(T+1)*T/2;
	printf("%I64d\n",t*6+1);
	return 0;
}

#include <iostream>
#include <vector>
#include <limits.h>
#include <math.h>

using namespace std;

int main()
{
	long long n;
	long long ret = 1;

	std::cin >> n;

	long long sum = (1 + n)*n / 2;

	ret = sum * 6 + 1;

	std::cout << ret;

	return 0;
}

#include<bits/stdc++.h>
#include<iostream>
using namespace std;
long long int n,m,i,j,sum,sumend;
int main()
{
    cin>>n;
    cout<<(3*(n*(n+1))+1)<<endl;
    return 0;
}

/*
Love to code
...............................
.                             .
.                             .
.        s_agnik1511          .
.                             .
.                             .
.                             .
...............................
*/
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<numeric>
#include<vector>
#include<math.h>
#include<map>
using namespace std;
#define dude             ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mesc(number,character)   char f[number];memset(f,character,number);
#define mesi(number,value)   int f[number];memset(f,value,number);
#define fr(i,start,end)  for(i=start;i<=end;i++)
#define rf(i,start,end)  for(i=start;i>=end;i--)
#define tst              int t;cin>>t;while(t--)
#define ai               ll n,i;cin>>n;ll a[n];
#define pi               3.14159265358979323846
#define ll               long long int
#define ld               long double
#define pb               push_back
#define r0               return 0;
#define pp               pop_back
#define vec              vector
#define S                string
#define D                double
#define len              length
#define br               break;
#define wh               while
#define F                float
#define gcd              __gcd
#define sz               size
#define endl             "\n"
#define sp               " "
#define MAX              266
const ll ifn=-1000000007;
const int N=100000;
const ll inf=(1LL<<60)-1;
    //vec<ll>arr(N,-1);
    //ll arr[N];
    //memset(arr,0,N);
ll power(ll x, ll y, ll p) {
    ll res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
void swap(int x,int y) {
    int t=x;
    x=y;
    y=t;
}
bool vow(char c) {
    if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='A'||c=='E'||c=='I'||c=='O'||c=='U') {
        return true;
    }
    else {
        return false;
    }
}
/*int facti(ll x) {
    if(arr[x]!=-1)return arr[x];
    else {
    if(x<=1) {
        arr[x]=1;
    }
    else if(x==2) {
        arr[x]=2;
    }
    else {
        arr[x]=x*facti(x-1);
        arr[x]%=1000000007;
    }
    return arr[x]%1000000007;
    }
}*/
bool isPrime(ll n) {
    if (n<=1)  return false;
    if (n<=3)  return true;
    if (n%2==0||n%3==0) return false;

    for (ll i=5;i*i<=n;i=i+6)
        if (n%i==0||n%(i+2)==0)
           return false;

    return true;
}
int chek(S s,int i,int j) {
    ll cnt=0,k,a;
    fr(k,i,j) {
        //cnt=(cnt*10)+(int(s[k])-48);
        a=int(s[k])-48;
        cnt=(cnt*10)+(a);
    }
    return cnt;
}
void solve() {
 ll x;
 cin>>x;
 x++;
 ll i;
 ll cnt=0,v=0;
 if(x>1) {
     v=(((x+1)*(x))/2)-1;
     //cout<<v<<endl;
 }
 v*=3;
 cnt+=v;
 v=0;
 if(x>2) {
   ll j=x-2;
   v=((j*(j+1))/2);
   //cout<<v<<endl;
 }
 v*=3;
 cnt+=v;
 cnt++;
 cout<<cnt<<endl;
}
int main()
{
    dude
    //memset(arr,-1,N);
    solve();

   r0
}

#include<bits/stdc++.h>
using namespace std;
long long x;
int main(){
    cin>>x;
    cout<<3*x*(x+1)+1<<endl;
    return 0;
}

#include <iostream>

using namespace std;

unsigned long long int n,ans;

int main(){
  cin>>n;
  ans=n*(n+1)*3+1;
  cout<<ans<<endl;
}

#include<bits/stdc++.h>

#define all(a) (a).begin(), (a).end()
#define x first
#define y second

#define oo 1e9
#define pi acos(-1)
#define MOD 1000000007

using namespace std ;

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }
typedef pair<int, int> ii ;
typedef vector<ii> vii ;
typedef vector<int> vi ;

int main() {
    //freopen("a.in","r",stdin) ;
    //freopen("a.out","w", stdout) ;

    long long n ;
    scanf("%I64d",&n);
    long long ans = 6*n*(n+1)/2 + 1 ;
    cout << ans << endl ;
    ///cerr << "Time elapsed: " << clock() / 1000 << " ms" << endl ;

     return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <functional>
#include <vector>
#include <numeric>
#include <deque>
#include <bitset>
#include <iostream>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int,int> pi;

int main(){
lint n;
cin >> n;
cout << 3ll * n * (n+1) + 1;
}

#include <iostream>
using namespace std;
int main(){
	long long n ;
	cin>>n;
	cout<<3*n*(n+1)+1;
}

/*
                                                            .sIj25dZMDdI1vi            .7sXdBJ          DZP          MQ7
                                                          .LUXSKIJr:.                      :7IE57ivbdgqPgQ: :rr..:.  Lgg
                                                       :IMBgPji.                    .7KPEbbX52ZBBQPPQBBMggDPQQMRBBBBQIQRQ...
                                                     vZBMSr.                    :i:rgBBQBBREZdZDMbPqUvZQDZZZQREISIqdBR17gZb...rr:.
                                                  .UBQIi                    .ir::2BQqjLPPrrrrrJPDdZdZQBgQDZZbIXXPPKuSKLuSMdji  :vvr
                                                .PBZr                    ..ri..vEbY7r77sisdMDEIujPgQZPuYjMMggRgRPLrrr7v7Sq51dd7  .isv.
                                              .XBS.                    .rr:. :X5L77vL77LqZDIYrrsdZKYvr7rrLgPqMgDgDgPurvr1XSrLYjXs   :vY.
                                             UQ5.                    .:r:.  iSJvvvvvrLPRPurrrIZBq7r77LvL77sg7JdRgQgSZdv7vq5vLj:.YK:   .Lr
                                           iBK.                     :i:. ..iIYLvLvL7sdEJLr72QQQMQXYYjssvIZdMqi7UKjPL72g175X7LvUr .Ji.   :7:
                                          PM.                      ::. ....5uvvLvv7JEKvY7YgBP1UMbPXSU1YsJu7sPv7JZ77YYv7PSX5v7YL2v  :.:    i7
                                        :MY                      ::. .:.. rIL7vvL7YESvsvuPS77rvv77vvLLsLYvYv1YvvBSvLjsLrIEUrvvYYKu.  .i.   .7.
                                       vg.                     .r:  ::  ..u17LYL7vPS7sYJ1Y7vvYvLvYYsLsYJYsLYvsvvMMjYsjsvrXZv7LY7.Lur.  ir.   r.
                                      KP                      .r. .:ri.. .ILjuvvv5XvYY1YLvLvsYJLYLsLsLsLJLsLsLLrZZbLssJvYXPRvrLs. .rJi  :Yi   r.
                                     qs                      .:. .ir2PIv:21uu. r1KvsL5JvLYLsLsLsYsLsLJLsLJLsYJYrqZXKvsYsXu UQvrur   i2r  .uv.  r.
                                    Ki                      ..  ivvIIjUJ21us.  .DLjsIUvvsLYLJLsYJLsLsYsYsYJLsYj:PDUbUvJsd:  ZB77j:  .jIJ. .UI:  r.
                                   2i                      ..  JUYI1JJsuJuJ:  .E2J:LqY7YLYLsvJssLJLJYsYJYJLsLJs:QR1qqvL52   .BbrvUs. s12I: .SXr  1.
                                  r7                      .. .DKYU1sususjjLvr.RELs7uuvYLYLYvsuJYsYsYsYJsJLsYssJ.QM1jRJYS2i.  sBur7jj77JsU5i :SSv  Q
                                 .L                      :  7BPL12uusjJusjLsvXQsvJqIYLLYYYvYqU7vJJYssJLJLsYjsJv.5BJvZQsus2Yu:iZBvr7YYjLsY1Ir vU5v :M
                                 v                      : .5Bd7u52XJuJjJjsYvvDP7sIIYJvsvYv7E1::vIsuJUuJYjLs77YrirDu7SBbvuJuYJrUQgr77LLsYJsU17 IYPi Ss
                                :i                     . rgBg7jS2KUssuJuJJY75Q2v1KsuLLLYL7UB7r::71sJri:51rr7rLrd.PJL5vP5Ljjs777gEPrvvJLsLsYu1::qud. M
                                i                     ..1MBQ7vqISX2YjjusJs17MZuvKuJsYvsL7YBE7LY. .... idLi777ijQ u1YP:iBYsuJL77EKqUrLYsYJsJssY.X5XK iX
                                :                    .:XgQQUrqSS5XjjsujjLSY2gPvIqYsjLYv7YEQUr777...iriSdr7r7riPP v1u5i PbYsuvvrbb1K77JssYjsjssr2gSqj d
                                .                   .i2ZBRZiPKS5XS1suJjYJKLEg2Yb5YuYLvvLPZB7rr77vrvLv7gUrr7rrrQr LXYS:..djJssv7IgsZu7YjYjsusuL7uBqPP:iJ
                               :.                   isZgQQvubSIS5KjJJjsYPSJRb1uZLsYY7v7SqqIri7r77777isgvi7rr:jRi.71LU:..iSLjYvr1QuPR7sJjsuJujj77MgbZU.S
                               r                   ivMUjBqrdX255S5JJ1JY1QsPMKjKS7vY7rrIPX.UirrrrrrrriSXrrrrriPZ. i1v2.:..JuLs77sBU2Q5vJJjsuJuJLrPMZZq:r.
                               r                  .LbQ DQLJZ2SIS5SsXjJvgEJgDUjq1rv77iUKb.iXrirrrirrivqsirrrrrEY. rYYY.::.ruvvvvJQquMEvsujuJus1L7UBdgKJ:.
                               i                  LIB: QZiPX5ISIS2IKs7PMS2RPjLEvr77r1Kdi vXiriririr:Id2:rii:Lqi .iU1L:i:::ULvvrvBEUdQLYJus1JujJ7JZgZq27.
                               r                 ijBP .B77ZS25ISI5qq7jMduPgXvuP7r7ruqqv  J2iiriririvdE7irrirI1.  iYu:..:..7u7jivQR2PQ2vjJuJuj1uvs5PRKILi
                               i.                JEB. 7BiUZ25IX552DI7qB22EDUY2di7rvLKU.. sIiri7rriiXjrririisEi   iUv....:.:j7YirvBqXBKvJ1JjJ1jULv5bMbU1i.
                                .               :PBU  1B:bP5I525IXDuJEguSRPuLUv7r1:sK:.: U1iir7riisY.7iriirP2    rU: .     7vJ:: bgqMd7u1jsuJuUJigQQP5U:.
                                                5gB   qE:DP2S25I2KMYIYPjIMbs5:rvs7:Xv....jXiirsii7s..vririqE:    vr ..iiri.:v. :.:QEgdvJ2suJuJI1iERgDIjS .
                                               .ZB1   QIigXSIII51ZEjL:P2jgqUU.ijv.:I:::..vKr:s7i7s..:virrvKv     77qDQBBBBQDq:  . LQZg7UUssuJJ2X:Z7qgXLR: .
                                               :QB    PY7g5IX2S25ZE2:.DuXbLXi :Ji ri..:. 7P7rur77:..77rrj:u     UBg1RBBBBQBZRBgi. .PQgr22vsYjsSXrj:KMKjEP r
                                               LQP  . jsYQIS5522XgZS.iD2E7L5.. :..:: ..  7Pj1U7r.. .v775: .    L5:.gBBBBBBQBQ1QBP. rQMrbYvvJYJ55iviQgbsIQ  :
                                               jB:  i Jj5g5IS2IjbDQJ rQ5u.Pr  75SI5UL7.   PXLLr.   :Jj7i      .. .BBRggdDbZgBE:DBQ. ggvB77YLsYKYivPDQKYuBi :
                                              .qB  r  rSPQ255IuIZggr rQq:.U :QBEQBBBQBQS: rK.r.    iY.           EBjrLDQggZggBv.DBM iq2Br7vYLJbL7dKEM5YURg  .
                                              .M1  r  rqbDS2qUUXgZg: iBS. iUBd:dBBBBBQBZJ. i                    :B:.JBQZMMRDMBR.:EBu.7QPr7YLYsDIggUZMuuuBQ2.
                                     . . .    .Q. i.  :ZKZI5PI1ddZBi :B7 .gB1 DBQBRRDMQBB7                      .   iUKXKZgDsQg ::ZD7sBJrLvL75ggRdsgM2jUQBB5r.
                                    .        ..Z  L   .ZPEPUE1SddPBP .R: qB1 sBBPPggRgMgBB:                     uBRgPYvvPI2XSi. ::PJ2iD7vvLvLbMdPdJggS1SBSgQuj.
                                             ..1 i:    bdEP1dXSEPbMB7 r.iBd. BBvvDRgSEgRgEZ                     PB7.    . :JqB.  i .L.SL7Yv7IgEqPgUMEPjdB7 QEUX
                                             ..: Y.    vQPdjZPKddPRDQ:  UBv. BP .qPES1qgBEP.                    :D  ...    .Pg     ::ibvLv7YQMdSbEPgDdIdBi  Q5I2
                                             :.. 1     .BdEXXDPEPPgZgZ  qBv. .  .JiXDUiJvvBB                     vJ.   ... .2.       PSLv7vRggqPPDZDEZqgMi   Rjq:
                          .   . .            .. i7  .   QDqbSEZdEPgZPRJ vMP   DBBEXL:. .   J                      ::    :i7:    .   rDU77vDdgSPXDMDERdbQg..  .Rur
                         .                   :. 7:      qB5dbbbEPbdEqbQv .Y    BBXs   .  ..:          ..             .......   ...  KXL7ugPPDSXdgBDMX7SBX     7Qr:
                                             .:.1.      IBXEQqdddPEEbqZBv .     idY  .    :           ..             .......:.:..  YXsvSMdb1d5uDBgKLr7gB7 i    PP :
                         .                   .::R       7BqdXgDEbEPZPPPB2..       ii::.. .                           ............ rILsXEPZK125IMXL77r5RBr i     B...
                                              r.B.      7BZYPZQgdPddEPgZ .:.       ::...... .                         .........  iq1jIPKDbK1SPXv7vY7vqBQj..     sL .
                                              ..22      7BU1ZdbMDEddddQ7  ::  . ............                             . . .  vD7XPPXEEE5Kb27vLsv7jZQgs. .     U :
                          .                    :iBr     SR7EqddEgEZdEERdr  :. ..:.:........                                   :uS. PdqDdbEZPJ7YYsYLvPQZE1i       ii.
                                               ..5BY   iDLjbudbddEdEdgEdQRI5v  ..:...... .          .i7JJ1uUjY:            . .:.  7QPDPKRQKv7sLsYs7uQEKDLZ.       7.
                            .                    :ZRbi7qs7X5IbqPZbEdDbPPPEgKZL  .......           .J5Yr:....:r5Y                 :BbZP5RQU77sLJsu7:ZMSPbvEZ .     v.
                                                  iMggKsvuSS5SKDEZdbPPSKKgKKSMs    .             :Ps:. ..... ..7.               :BgdPPgMs7vsYjj27.KBKqqP7YB :.    I.
                              .        ..      .:r2s.rsvYXXII5DEgDK5DKqKDdKKPPBU                 .s..............              rBgdEdgML7vYYu22i uBEEKd5v7R. .    X
                                       ........i:rr iXvsIK5IUdERDXJgPPqdgPKPKPdBP                  .............              SBDgg5qQY7vssIU7. 7BZ7ugP1vvXr :   J.
                                                .: iQ5v1KS5UqDQdIsbEbELPDqPKPKPPBR                  ..........              7BBbMgL1Bs7LJs5L.  vBZg1:BPLvv1:.r  :.
                             .                 :: .QSvYUSX25RgussXggR:uRqqPPqPqPPQB:                   . .                rQBgPMZrsBu7vjJIr   uBgPMD Q2v7Y2 .r
                          .                   .r .7u77v1q2IgbrsUIMQR :BEXqdqPKqKPPgQP.                                 .uQBgdqQqrvQs7LJJs:.::5BRd5Bg K57vY2 i:
                     . . .                    i ::Yj7v7IIdM1iY22gBM  BDbUddPKPXPKPPEQBgL.                           .JBBRgPPqQXrrBi:JJYi:rYrXRMMSvdE 12vvKr 7r
                    .                        :.. :dvv7jSbg27v22dBQ  bgMSIEgqPqqXqKPqbbMBBg5i.                    .iLs:bQPKPKRSirQK 7jYvrjLrqggRqd.Qi 1UL2P  u:
                                             ..  LSL7vPg:ss2LS5BR  .BdZ2UDEbSqXqXPKqKPKPdgQBBBDQRI:.          .i7sr:. vQSqXMPirgB.rusJYu77EMgQP5 .Q  PIqX  .b
                                             ..  :1LvKg i2K221BB   jBqP1IdgPqXKKPXqKPKqKPqPqEdEBBvir7r7iri:.irvri:... UBDqDgrrgQu.1YsLLsbBBBBbPi EI 7gr   .J.
                                             .   .2L2Z  XuKIUXB:   bZq5I2EZEKqSddqqPKPKPPdgQgqPB1 .:iiiiirrrii::..... vBQq2u7QQBirJJLvED1vri. .Bu2BLv     :
                .                           ..   :Sug  .P1qU2Q5    dgXX5SPMDEqPQMqPPPPgDBQZr IBQ7 ..::::i:i::......  .SDB5JLbQDb:ssvvBE        rB BP
                                            :.   :Xq.  .d2KXXBJ    dBRMRgQQBBBgBBBQQRBBg7.  :B1Q: .......:....... .:7SSgDEub   urJ7vQK  .. ...  Q.IB.i
                .                           ..    q7    QEggBBP .. :ji7:ii7rir:iv77rLI:     bEuIP:  ......... ..irsu1UMgg2Zi   gsrLQL   ......  ZiLB.:
                 .                           .    ir    LM1v:.                             :Qq2UIds:.. .  ..ivvjJjYJ1gggBB1   iB7LBJ           1B.BB
                                                  .r.                             . .     .QBu55S1I12vi:rLssULvvYsJ5QRQQBB.   LQYgK           iQiBB .i
                                      .....i7IbQBQgRQQKv:..                      ...      iBRU1SXXI5UII5I2u1j1JUjUqQQQZB:2.   7BPR           vU KB .JPi
                                      .:rr7r7ii::..:rYPMKSP1jvv7r.               ..       :QBdUuKdP25U2U225U52I1XDBDKXBi .:   .BB.          us.jr ivi.:
                                           ...            .:rIvi:vv.             ..       .BQRDPu2ZMPqI2UU1U2PdRgZUuPB7   :    BE         .Ui.v:.i.  .::
                                              . . . . .  .7:  .sY..jr            ..        BBgMMgK1XRQMEdPZgQQgqUs5BBi         BY        :j.:r:.. . .:.:.
                                       ..........i::... igggPs. :2r iu           ...       DBQggMQD21MQMRQQQb2YJ2gBB:          vs       7r.i::.  . .:. .:
                      .         ....:::::::.:::...::i:::DIYvXEgs  7J..U:      ..  ...      7BdQgggQMSjZMMdP1JsSdQBB:            Z     iv::i:.   . .:. . i
                           ....:::.:.................. :ii:i..:s1r :U: si    .      ..     .BU5QDggggEU2jJLJ5DMQQB7             .:  :s7:i::.  .. ... .  ::   .
                        ..:.:........................ :i:ir.     .i .uv rv                  ZB1IMDgDggMP2uKZQMMRBK                iLrii:.:. ....... ... .i
                     ..:.:.......................... .7ir: .       :. vu.:Ii                rBQK5ggMgggQRQQQgMRBR               :Li:i:.i:  ....... . ... r     .
                  ..:............................... r7:.  .. . ... :: iX: J1               .BBBgdRRBBBBBBQQQMRE. .           i7i:7i.rLi  ... ....... .  i.     .
                ................................... .U:.   ... ..... :r :b7 id:              gBBBBBQMgEDRBBBQgE.            isi:7r.i2vi. . . ....... . . i.        . .     .
              ..................................... vY  . .  .. ...   rs..qS. Pj        .    iY:.          .:rv:7i.      .UJriY7..IIi:i . . .r. ........ :i                 .
            ........................................I: ... . ... ...  .r5. Ydi 7D7     ...                      .::rv7:vQBuuBP..sPv::r.  .  v. . ... ... .i                  .
          ........... ... ...............   ........v ..... . ... ...  iiIi .Dg:.Pgi...                              .:1Z1BBr.jPSr::ir. .  7r   ..... ....r
         ........... ..... ..............JK7 ..... ii  ....... ... .   i::uX::QB5...                     . .              :.vQg2i::iir .. :u   . . . ... .r
       ...... . . . ..... ...............dBM: .... 7i ... :.:.. ... .. .r::vE7..                                             .vLLrri7r   :P:  . . ....... r
      ...... ... ... . . ... ........... :ggS  ... J......::.:.  .:. . .rrr:.                                                  .iuYr7r  .5v  .............7                  .
     :....... . . . . . . . . ........... 1DM: ....L......:...:.  .Y. . ri.                                             .   .     ruL: .Ss: ..............7
    :: ..... . .     . . . ... .......... .DgK ....u......::.:.:.  7U. .                                             .     .       .5r 5v7 ............. .r
   .i ... . . .       . . ................ rQMr ...K: ....:.:.:.:. .5U.                                               . . . . . .    7Pr7. .......... ....r               .
   7 ... . . . . .:.   . .................  2Bb .. 5: ...:::::.:::.:v.     . . .                             .r7v.     . .   . .      idi  ......... :7J.:i              .
  7:  . . . . .  rgX.  .................... .J: ...7i ...::::.::::vi    . .                                  YgSZ7    . . . . .        .K  .......  :vL7 i:
  v  . ... . . . .Xqq.  .....................  ... 1i ...::::::::7:        .     :vq:                  .     iKjUu     . . . . .        .P. .... ..777L. 7.
 ii ... . . . . . .qPP. ...........................qY ...:i:::::7.    .   .     :ZXIX                        :PYU2  .   . . . .          ib     :7Lr7vi .u.                 . .
 v.... . . . ....  :qbS  ........................ rEI. ..::::::7.  . . . . .    .djJX7                       :PjuK     . . . . . . .     .v5 .ivv7rr77  75
:r .. ... . .....   :qQX ........................ qsP: ..:i::.Y:    . .          25YJK      .       . .      :ZJ1d  . . . . . . ....     ..JSrvr7rr7L  rvu                            .
Yr ................. .17 ....................... iqi5r ...:i.7s  . . . . . . .   :EjYKL    . . .     . . .   :DIUg   . . . ... . ...   ..::.Pj:iir7L. iLr5
Z:. .................   ........................ r1:Sj .. .::d.   . .   .     .   UKjJg.  .   . . . . . .     DZMU  . . ... .......    .::::iqvLi7v. .Yr7U
R............................................... LYiuP  ... rU   . . . .     . .   EKIbE   . . .   . . . .     .:    ..... . ... . .    .::i:uiLPr   :vrrL                               .
Q.:............................................. 7J:JEr ... 1:  . . . . . . . .    .REXL  . . . . . . . . .       . . ... . . ... .      :vIsi2 :i   :Yr7s                                .
Q............................................... ru:vP2  ...d    . . . .   . . . .   .     . . . . . . . . . .   . . ..... ... .     . ..Jb7  Qi :i  .v7rI                               .
R::...............................................d:L5d:   .g   . . . . . . . . . .     . . . ... . . . . . . ... . . . . .        .UEqjKv   .Q7 .u . :L7j                                .
Xr::............................................. dr7XSX   :d.   . . . ... . . . . . . . . ....... . ... . ... ... ... .     ... :PPi.:1dXr. jJ7 .u .. isj                             .
rv:::............................................ Ivi2SP7  :Z.. . . . . . . . . . . . . ......... . . ... ... . . ... .  .:ii::.  :vPU:  :KXIJr: .2 ... vj      . .
 U:i:............................................ 7U:r2EEr .Q..    . . . ... . ..... . ..... ... . . . ... . ..... . . .ir.          rEP:  :UqXL .P. .. :I .:i:i:::::.........
 JL:ii:.......................................... ivrirYEQY Q:.   . . . . ....... ... . ....... . . . ....... . .      v.r7i:.         LMX.  rPqr.::. . v7....................:...
 .P:ii::.....................................:::::r7iririvZKBv:.   . . ....... . . . . ......... . . ..........       ILYIr7LsLi        .2gY  :q55  7.  j. ......................:::.
  Dr::i:i:..................................::::i:rvrr7i  .7QP::.   . . ..... ... . ... . . ... . . . ..... .    .r7SKq7:  .iirrYr        iDP. .XS: J  iq ..........................:i:
  iZ:iii:::................................:.::i:i:Ji77. .  iBii:    . . . ... ... . ... ... . . . . ... .    .rY1Ys7i.  .  .iiri7jr       .XE: i5JPi iIv ............................:r:
   KJ:iii:i:..............................:::::iii:Yrri....  Ij:i.  . ... . . . . ..... . . . . . ... .    .i7Yri::.. . ... ..::rirs5:       2b7 v1Xr.7Ui ..............................:i:
    gr:iiiii:............................::::iiii:iRLii. .. r.vri:         . . . . . . . .               :iri.     ......... ..  .  .Li      iI5i.LZQY:S......   .........................:r.
    .Dr:iiiiiii:::....................::iiiiriiri:rbQiri  . u .1Y7.i:                                 :iri.     . ... ....... . .     vi   .. 7UI iBBXiL .... .::...........................ri
     .Pv:iiiiririri:::.:...........::iirrrr777ri.:. ggJv:   :J :ZY ..::v1r..           ...:i7JLY7vjXdb7:   . . . ................... .77  .:..:S2. BBXrr ...  75U. ..........................i7
       22iiiririiirii:i::::.:.::::iiiirir7vri..   v  iKPS:   rr .K  .uQq: :gPr::i::ir7Lj2jusv7sss2QB2   . . . ..... . . ........... .irr: :....vZ: QBYr..... 7dK7 ............................:v.
        iIvriririiiiiriiiiii:iiiiririr7vr:        ri   :LKr.  r:  7KPX:  su: iKZjusY7r:....:irirvL.    . . . ... . . ... . .....   .ii:rv..:.. 1B. BB7s ... iZPq ...............................7.
          rvL77rriiiiirrrirrrrrir7v7r::            P.    .ii.. r rBBB..Lu:    .r.     .:i77r::ir.     . . ... . ..... . ... . .   .ii:::1..... BB .BB.7:....PPd. ................................v.
            .:r77777r7rrr7r77Lvs7r..               Xv. ...  .. .YBZ2. 77..       ..i7sY7i: .:r:    ... . . ... . ... ... .....  .:ii::.:b....  BU gB: .7.. SZD: ..................................L.
                 ..:iirrrrrii..         .          2J7. .........    .:..   ..irsjj7i..   .::   ......... ... ..... .......   ..:::.::.PB ... JB  B5 .2...iZPi ...................  ...............U
                                         .   . .   2s7r. ... . . ... .    .rJUuvi:.. ...::................................  .irii77Lss5BB .:  Bg BR  Ei..........:.:............. iSr..:.:.........iJ
                                                   :u.::. . ...           .:..         ::                                 .:rii7u12j7L:.Y .  PB.rj  rK. ... . ...................vDq. ............. r:
*/
/*根据所给顺序取节点然后在bfs序列中找与所给的是否相同*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ten5 100000+10
#define MOD 1000000007
#define rep(i,a,n) for (int i=a;i<n;i++)
#define iif(c,t,f) ((c)?(t):(f))
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define me(x) memset(x,0,sizeof(x))
#define ms(x) memset(x,0x3f3f3f3f,sizeof(x))
const int  inf = 0x3f3f3f3f;
int intcmp(const void *v1,const void *v2)
{
    return *(int *)v1-*(int *)v2;
}

inline int read()
{
    int x=0,f=1;
    char cc=getchar();
    while(cc<'0' || cc>'9')
    {
        if(cc=='-') f=-1;
        cc=getchar();
    }
    while(cc>='0' && cc<='9')
    {
        x=x*10+cc-'0';
        cc=getchar();
    }
    return x*f;
}
int main()
{

ll n;
n  =read();
ll ans = (n+3)*n+n*(n-1)*2+2*n+1;
cout << ans <<endl;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long n;
  cin>>n;
  cout<<6*n*(n+1)/2+1;
}

#include <iostream>
long long a;
int main(void) {
    std::cin >> a;
    std::cout << (a + 1) * (3 * a) + 1 << "\r";
}

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
long long n;
int main()
{
	scanf("%lld",&n);
	printf("%lld",1ll*3*(n+1)*n+1);
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    cin>>n;

    cout<<n*(n+1)*3+1<<endl;

}

#include<cstdio>
#include<algorithm>
typedef unsigned long long ull;
int main()
{
    ull n;
    while(scanf("%I64u",&n)==1)
    {
        ull ans = 3*n*(n+1) + 1;
        printf("%I64u\n",ans);
    }
    return 0;
}
/*2016-02-21 19:54:27.026*/

#include<iostream>
using namespace std;
int64_t n;
int main()
{
    cin>>n;
    int64_t m=6*((n*(n+1))/2);
    int64_t k=m+1;
    cout<<k;
}

#include <iostream>
using namespace std;
long long calculate_sum(long long m)
{  int a=6;
    // Number of multiples
 //   long long m = N / a;
    // sum of first m natural numbers
    long long sum = m * (m + 1) / 2;
    // sum of multiples
    long long ans = a * sum;

    return ans;
}
    /*

    */
    // C++ program to find sum of multiples of a number
// up to N efficiently
// Function for calculating sum of multiples of
// a upto N
int main()
{int  n;cin>>n;    if(n==0){cout<<1;return 0;}
    cout<<calculate_sum(n)+1;
    return 0;
}

#include <iostream>
using namespace std;
int main()
{
    long long int n;
    cin >> n;

    cout << 1 +  3*n*(n+1);
    return 0;
}

#include <iostream>
#include <string>
#include <algorithm>
#include <bits/stdc++.h>
#include <stdio.h>
#include <stdlib.h>
using namespace std ;
const int Max = 10055 ;
long long gcd( long long a , long long b )
{
    if ( b == 0 )
    return a ;
    else
        return  gcd ( b , a % b ) ;
}
 long long lcm ( long long  a , long long b )
{
    return ( a* ( b / gcd ( a , b ) ) ) ;
}
 bool leap( int  y )
 {
	if (  ( y % 400 == 0 ) || ( ( y % 4 == 0 ) && ( y % 100 != 0 ) ) )
        return 1 ;
    else
        return 0 ;
 }
int main()
{

      long long n , sum = 0 ;
      cin >> n ;
//      for ( int i = 1 ; i <= n ; i++ )
//        sum+=( 6 * i ) , cout << sum << " " ;
//      cout << sum << endl ;
      if ( n == 0 )
        return cout << "1" , 0 ;
      cout << ( 1+( ( 3 * n ) * ( n + 1) ) ) ;
         return 0 ;
}

#include<bits/stdc++.h>

  using namespace std;
// function to print string in sorted order
void sortString(string &str)
{
   sort(str.begin(), str.end());

}

// Driver program to test above function
int main()
{
    long long int n;
    cin>>n;

    cout<<1+3*n*(n+1);

    return 0;
}

#include<bits/stdc++.h>
#define fora(i,a,b) for(int i=a,Wub=b;i<Wub;++i)
#define ford(i,a,b) for(int i=a,Wub=b;i>=Wub;--i)
#define SPEEDIO ios::sync_with_stdio(0);cin.tie(0);
using namespace std;

int main(){//SPEEDIO
    long long n, suma=1;
    cin>>n;
    suma=((n*(n+ 1)/2) * 6)+1;
    cout<<suma<<"\n";
    return 0;
}

#include <iostream>
using namespace std;

int main()
{
	long long int n;
	cin >> n;
	cout << 3 * n*(n + 1) + 1; return 0;

}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	ll n ;
	cin>>n;
	ll ans =1;
	ll cnt = 6;
	/*for(int i=1;i<=n;i++){
		ans += (cnt);
		cnt += 6;
	}*/
	if( n >= 1){
		ans = ans+(n*(6+(n-1)*3));
	}
	/////////////////
	cout<<ans<<endl;
}

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
// const long int N=1e9+10;
int main() {
	// your code goes here
	long double n;
	cin>>n;
	long double ans=3*(n*(n+1))+1;
	cout<<fixed<<setprecision(0)<<ans;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main () {
    long long n;
    cin >> n;
    cout << 3*n*(n+1)+1;
}

#include <iostream>
using namespace std;
int main()
{
    long long int s;
    long long int n;
    cin>> n;

    s=(((n*(n+1))/2)*6)+1;

   cout<<s;

}

#include<iostream>
using namespace std;
int main()
{
long long n,s,m;
cin>>n;
s=(n+1)*n/2;
m=s*6+1;
cout<<m;
}

#include <bits/stdc++.h>
using namespace std;main(){int a; cin >> a; cout<<3ll * a * (a + 1) + 1;}

#include <bits/stdc++.h>
using namespace std;

int main(int argc, char const *argv[])
{
	long long int n,ct=1;
	cin>>n;
	if(n!=0)ct+=(6*n*(n+1)/2);
	cout<<ct<<endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

int  r = 6, u0 = 0 ;
long long int A = 0 , n ,um;
int main(){

	cin>> n ;

	um = u0 + (n - 0) * r;

	n = n + 1;

	A = n * (u0 + um) / 2;
	A = A + 1;

	cout<<A<<endl;

}

#include<iostream>
using namespace std;
int main(){
	long long n;
	cin >> n ;
	long long ans= (((n*(n+1))/2)*6)+1;
	cout << ans;
}

#include <bits/stdc++.h>
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%//
#define pb push_back
#define ret return
#define SWStdio ios_base::sync_with_stdio
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%//
using namespace std;
typedef string str;
typedef vector<vector<pair<int, int> > > vvpi;
typedef vector<vector<int> > vvi;
typedef unsigned long long ull;
typedef long long ll;
    ull a, b, c = 1;
main (){
    SWStdio(false);
    cin >> a;
    c = 1 + 3 * a * (a + 1);
    cout << c;
    }

#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;
const int maxn = 105;
typedef long long ll;

int main()
{
    ll a;
    while(~scanf("%I64d",&a))
    {
        printf("%I64d\n",a*(a+1)*3+1);
    }
    return 0;
}
/*2017-04-18 22:23:03.956*/

#include<iostream>

using namespace std;

int main()
{
    long long n;
    cin>>n;
    if(n==0)
        cout<<"1"<<endl;

    else{
    long long s=(1+((3*n)*(n+1)));

    cout<<s<<endl;
    }

    return 0;
}

#include<iostream>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	long long n;
	cin>>n;
	cout<<3*n*n+3*n+1<<endl;
	return 0;
}

#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include<cstdio>
using namespace std;

__int64 a,b,n,c=0,d=0;
double x1,x2;

int main(){
    cin>>n;
    b=(((6+(n*6))/2)*n)+1;
    cout<<b;
    return 0;
    }

#include <iostream>
using namespace std;

//class name

class hexagons
{
private:
    long long n;
public:
    void setn(int n);
    long long  gethexa(long long n);

};

//member function....
void hexagons::setn(int  n)
{this->n=n;}
long long hexagons::gethexa(long long n)
{    return 3*n*n+(3*n)+1;
}

//main function
main()
{
    hexagons h;
    long long k;cin>>k;
    h.setn(k);
    cout<<h.gethexa(k)<<endl;
}

#include<bits/stdc++.h>

using namespace std;

int main()

{
    int i,j;

    long long int sum=1,x,y,n;
    //scanf("%d",&n);
    cin>>n;

    x=n*(n+1);
    y=x/2;
    sum=1+(y*6);

    cout<<sum;
}

#include <iostream>

int main() {
	unsigned long long n;
	std::cin >> n;
	std::cout << 3 * n*(n + 1) + 1;
}

#include<iostream>
#include<vector>
using namespace std;
int main()
{
	long long n;
	cin >> n;
	cout << (n*(n +1)) / 2 * 6 + 1;
	return 0;

}

#include <bits/stdc++.h>

#define pii pair<ld, ld>

#define pb push_back

#define f first
#define s second

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const int MXN = 1e5 + 1;
const int TMXN = 2e6 + 10;
const ll INF = 2e9 + 7;
const ll INFL = 1e18;

ll n, ans = 1;
int t;
int main() {
    cin >> n;
    cout << ((n * (n + 1)) / 2) * 6LL + 1LL;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main ()
{
	long long a;
	cin>>a;
	cout<<(a+1)*3*a+1;
}

#include<iostream>
#include<map>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<stack>
#include<set>
#include<string>

using namespace std;

#define fastIO ios::sync_with_stdio(false)
#define SP system("pause")
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORI(i,a,n) for(int i=a;i<n;i++)
#define MP make_pair
#define ALL(a) a.begin(),a.end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef pair<int, int> ii;
typedef vector<int>::iterator ITR;

int main(){
	fastIO;
	ll n; cin >> n;
	cout << 1 + 6 * (n*(n + 1) / 2);
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main(){
    long long ans;
    scanf("%lld",&ans);
    printf("%lld",(ans+1)*(ans*3)+1);
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long  n,i,ans;
    cin>>n;
    ans = n*(12+(n-1)*6);
    ans = ans/2 +1;
    cout<<ans;
    return 0;
}

#include<iostream>
#include <math.h>
using namespace std;
int main()
{
 long long int n,s;
 cin >> n;
 s=(6+(n-1)*3)*n;
 cout << s+1;
}

//BISMILLAHIR RAHMANIR RAHIM
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<string>
#include<set>
#include<cmath>
#include<cctype>
#include<stack>
#include<cstdlib>
#include<utility>
#include<vector>
#include<deque>
#include<queue>
#include<algorithm>

#define sc scanf
#define si(t) scanf("%d",&t)
#define sl(t) scanf("%I64d",&t)
#define sii(a,b) scanf("%d%d",&a,&b)

#define P(a) printf("%d\n",a)
#define PLN(a) printf("%I64d ",a)
#define pf printf

#define gcd(a,b) __gcd(a,b)
#define ff first
#define ss second

#define pr1(a) cout<<a<<endl
#define pr2(a,b) cout<<a<<" "<<b<<endl

#define pii pair<int,int>
#define pi acos(-1.0)
#define PI 3.1415926535897932385
#define Sin(a) sin((pi*a)/180)
#define siz 1000001
#define mem(ar) memset(ar,0,sizeof ar)
#define one(x) __builtin_popcount(x)
typedef long long ll;
using namespace std;
//int dx[]= {-1,-1,0,0,1,1};
//int dy[]= {-1,0,-1,1,0,1};
//int dx[]= {0,0,1,-1};/*4 side move*/
//int dy[]= {-1,1,0,0};/*4 side move*/
//int dx[]= {1,1,0,-1,-1,-1,0,1};/*8 side move*/
//int dy[]= {0,1,1,1,0,-1,-1,-1};/*8 side move*/
//int dx[]={1,1,2,2,-1,-1,-2,-2};/*night move*/
//int dy[]={2,-2,1,-1,2,-2,1,-1};/*night move*/
map<ll,bool>visi;
int main()
{
    ll i,n,n1,j,sum;
    sum=0;
    ll cnt=0;
    cin>>n;
    n1=n;
    if(n==0)
        cout<<"1";
    else
    {
        sum=n*(n+1)/2;
        cout<<sum*6+1;
    }
}

#include <iostream>
#include<cmath>
using namespace std;

int main()
{
    long long n,output;
    cin>>n;
    n=((n*(n+1))/2);
    output=(n*6)+1;
    cout<<output;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
int main()
{
    ll n;
    cin>>n;

    ll temp = n*(6+(n-1)*3);
     if(n==0) temp = 0;
    temp++;
    cout<<temp;
}

#include <bits/stdc++.h>
using namespace std;

int  r = 6, u0 = 0 ;
long long int A = 0 , n ,um;
int main(){

	cin>> n ;

	um = u0 + (n - 0) * r;

	n = n + 1;

	A = n * (u0 + um) / 2;
	A = A + 1;

	cout<<A<<endl;

}

#include<bits/stdc++.h>
using namespace std;
int main(){
long double n;cin>>n;
cout<<fixed<<setprecision(0)<<(6*(n*(n+1)*0.5))+1<<endl;
return 0;}

#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <vector>
using namespace std;
#define pb push_back
#define pd pop_back
typedef long long ll;
typedef long double ld;

int main ()
{
	ll n; cin >> n;
	long long int ans = n*(n+1)/2; ans *= 6; ans ++; cout << ans;
	return 0;
}

#include <iostream>

using namespace std;

int main(){
	long long int p,n;
	cin >> n;
	p = (n + 1)*n / 2;
	n = 6 * p + 1;
		cout << n;
	return 0;
}

#include<iostream>
using namespace std;
int main()
{
    long long n,i,sum=1;
    cin>>n;
    sum=n*(n+1)/2*6+1;
    cout<<sum;
    return 0;
}//2018-11-21 17:38:05.133

#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;
int main()
{
	long long n;
	cin>>n;
	cout<<6*n*(n+1)/2+1;
	return 0;
}

#include <iostream>
long long a;
int main(void) {
    std::cin >> a;
    std::cout << (a + 1) * (3 * a) + 1 << "\r";
}

/*Made by Shivam Solanki*/
#include<bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define ll long long int
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<pii> vp;
typedef vector<pll> vpll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef set<int> sii;
typedef set<ll> sll;
typedef priority_queue<int> pq;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;
typedef queue<int> qii;
#define rep(i,k,n) for (int i = k; i < n; ++i)
#define repr(i,k,n) for (int i = n; i>=k; --i)
#define repll(i,k,n) for (ll i = k; i < n; ++i)
#define repllr(i,k,n) for (ll i = n; i >= k; --i)
#define pb push_back
#define mp make_pair
#define gcd __gcd
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int INF = 1e9+5;
const int MOD = 1e9+7;

void solve(){
    ll n;
    cin>>n;
    cout<<1+3*n*(n+1);
}

int main(){
    // #ifndef ONLINE_JUDGE
        // freopen("input.txt", "r", stdin);
        // freopen("output.txt", "w", stdout);
    // #endif
    // fastio;
    int t=1;
    // cin>>t;
    while(t--)
        solve();
    return 0;
}

/*   ___   ___   ___   ___   ___   ___      ___   ___   _      ___   ___
    |___| |___| |   | |___| |___  |___     |___| |___| | \  | |   | |___|  |  |
   |___| |   | |___| |   |  ___|  ___|    |     |   | |  \_| |___| |   |  |  |
                                                                         .  .
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

*/
#include<bits/stdc++.h>
#include<string.h>
#define lli long long int
#define in(a,n) lli a[n];for(lli i=0;i<n;i++)cin>>a[i];
#define out(a,n) for(int i=0;i<n;i++)cout<<a[i]<<' ';
#define insum(a,n) lli a[n],s=0;for(int i=0;i<n;i++){cin>>a[i];s+=a[i];}
#define vin(v,n) vector<lli>v;for(int i=0;i<n;i++){lli t; cin>>t;v.push_back(t);}
#define vout(v) for(int i=0;i<v.size();i++) cout<<v[i]<<' ';
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define mod2 1000000009
using namespace std;

/*void SieveOfEratosthenes(int n)
{bool prime[n+1];
 memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++)
    {   if (prime[p] == true)
       {    for (int i=p*2; i<=n; i += p)
                prime[i] = false;
        }
    }
for (int p=2; p<=n; p++)
    if (prime[p])
      cout << p << " ";
}*/

/*
lli power(lli x, lli y, lli p)
{   lli res = 1;
    x = x % p;
        while (y > 0){
            if (y & 1)
                res = (res*x) % p;
            y = y>>1;
            x = (x*x) % p; }
    return res;
}*/

int main()
{

ios_base::sync_with_stdio(false); cin.tie(NULL);

     /*  lli t;
        cin>>t;
        while(t--){*/

   lli n;
   cin>>n;
cout<<1+((3*n)*(n+1));

              //  cout<<endl;}

	return 0;

}

#import<iostream>
main(long long x){std::cin>>x;std::cout<<x*(x+1)*3+1;}

// Example program
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
  long long a,b,c;
  double d,x1,x2;
  cin>>a;
  b=3*a*(a+1)+1;
  cout<<b;

}

#include<bits/stdc++.h>
using namespace std;
long long n;
int main()
{cin>>n;
 cout<<3*n*n+3*n+1;
 return 0;
}

#include <iostream>
#include <stdio.h>

using namespace std;

int main()
{
    long long n;
    cin >> n;

    long long x = 3*n*(n+1) + 1;
    cout <<x;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main(){
  int n;
  cin >> n;
  cout << (long long)3*n*(n+1)+1;
  return 0;
}

#include <iostream>

using namespace std;

int main()
{
    long long int n;
    cin >> n;
    if (n == 0)
        cout << 1;
    else
        cout << 1 + 6 * (n - 1) + 6 * n;
    return 0;
}

#include <iostream>
using namespace std;

int main () {
	int n;
	cin >> n;
	n = ((n * (n + 1)) / 2) * 6 + 1;
	cout << n;
}

#include <iostream>

int main() {
	unsigned int n;
	std::cin >> n;
	std::cout << 3 * n*(n + 1) + 1;
}

#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <stdio.h>

int main() {
	int i;
	long long int y=1,x, sum=0;
	scanf("%lld",&x);
	for (i = 0; i < x; i++)
		y *= 2;
	sum = y + (x+1) * 5;
	printf("%lld", sum);

	return 0;
}

#include <iostream>
using namespace std;

int main()
{
    int n;
    cin>>n;
    cout<<1+6*(((n+1)*n)/2);
}

#include <stdio.h>
void main()
{
	int n, an;
	long long int res = 0;
	scanf_s("%i", &n);
	an = 6 + 6*(n-1);
	res = ((6+an)/2)*n +1;
	printf("%I64i", res);
}

#include <cstdio>

#define LL unsigned long long

int main(){
    int n; scanf("%d", &n);
    LL s = 1, d = 3;
    d = d * ((n * (n + 1)));
    printf("%I64u\n", s + d);
    return 0;
}

#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;

#define LL long long

int main(){
	int n;
	cin>>n;
	LL sum;
	sum=(n*(n+1))/2;
	cout<<(6*sum)+1;
}

#include <cmath>
#include <cstdio>
#include <vector>
#include <limits>
#include <iostream>
#include <algorithm>
#include <map>
#include <iomanip>
#include <limits.h>
#define ll long long
using namespace std;

ll binpow(ll a, ll n) {
    ll res = 1.0;
    while (n) {
        if (n & 1)
            res *= a;
        a *= a;
        n >>= 1;
    }
    return res;
}
int main(){
    int n,t;
    cin>>n;
    ll res=1+3*n*(n+1);
    cout<<res;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()

template<typename T> T& input(T& v) { for(int i=0;i<v.size();i++) cin>>v[i]; return v; }
template<typename T> void print(const T& v) { int N=v.size(); for(int i=0;i<N;i++) cout<<v[i]<<" "; }
template<typename T> void print_2d(T& v) { int N=v.size(); for(int i=0;i<N;i++){ for(int j=0;j<v[i].size();j++) cout<<v[i][j]<<" "; cout<<endl; } }
template<typename T> void print_pair(const T& v) { int N=v.size(); for(int i=0;i<N;i++) cout<<v[i].first<<" "<<v[i].second<<endl; }
template<typename T> inline int digits(const T& N)  {	return (N>0?(int)((log(N)/log(10))+1):0); }
inline bool ispoweroftwo(int x){ return (x&&(!(x&(x-1)))); }
int binomial(int n, int k) { vector<int> C(k+1,0); C[0] = 1; for (int i=1;i<=n;i++) { for(int j=min(i, k);j>0;j--) C[j]=C[j] + C[j-1]; } return C[k]; }
inline double distance(int a,int b ,int c,int d){	return sqrt((a-c)*(a-c)+(b-d)*(b-d));	}
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b) { if(a.second==b.second) return (a.first > b.first); return (a.second > b.second); }
struct compare{  bool operator()(pair<int,int>& p1, pair<int,int>& p2) {  if(p1.F == p2.F) return p1.S > p2.S; return p1.F > p2.F; }  };

int main()
{
	ios_base::sync_with_stdio(false);
	long long N;cin>>N;
	if(N==0)
	cout<<1;
	else
	cout<<fixed<<0.5*((N)*(2*6+(N-1)*6))+1;

	return 0;
}

        #include <iostream>

        using namespace std;

        int main()
        {
            long n;
            long double out;
            cin >> n;

                out = 1+3*n*(n+1);
                cout<< out <<endl;;

            return 0;
        }

#include<iostream>
using namespace std;

int hexa(int n){
	if(n==0){
		return 1;
	}else{
		return hexa(n-1)+(n*6);
	}
}

int main(){
	int b;
	cin >> b;
	cout<<hexa(b)<<endl;
}

#include <iostream>
using namespace std;
int main ()

{
    int n;
    cin>>n;
    cout<<3*n*(n+1)+1;
    return 0;
}

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

/*
Love to code
...............................
.                             .
.                             .
.        s_agnik1511          .
.                             .
.                             .
.                             .
...............................
*/
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<numeric>
#include<vector>
#include<math.h>
#include<map>
using namespace std;
#define dude             ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mesc(number,character)   char f[number];memset(f,character,number);
#define mesi(number,value)   int f[number];memset(f,value,number);
#define fr(i,start,end)  for(i=start;i<=end;i++)
#define rf(i,start,end)  for(i=start;i>=end;i--)
#define tst              int t;cin>>t;while(t--)
#define ai               ll n,i;cin>>n;ll a[n];
#define pi               3.14159265358979323846
#define ll               long long int
#define ld               long double
#define pb               push_back
#define r0               return 0;
#define pp               pop_back
#define vec              vector
#define S                string
#define D                double
#define len              length
#define br               break;
#define wh               while
#define F                float
#define gcd              __gcd
#define sz               size
#define endl             "\n"
#define sp               " "
#define MAX              266
const ll ifn=-1000000007;
const int N=100000;
const ll inf=(1LL<<60)-1;
    //vec<ll>arr(N,-1);
    //ll arr[N];
    //memset(arr,0,N);
ll power(ll x, ll y, ll p) {
    ll res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
void swap(int x,int y) {
    int t=x;
    x=y;
    y=t;
}
bool vow(char c) {
    if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='A'||c=='E'||c=='I'||c=='O'||c=='U') {
        return true;
    }
    else {
        return false;
    }
}
/*int facti(ll x) {
    if(arr[x]!=-1)return arr[x];
    else {
    if(x<=1) {
        arr[x]=1;
    }
    else if(x==2) {
        arr[x]=2;
    }
    else {
        arr[x]=x*facti(x-1);
        arr[x]%=1000000007;
    }
    return arr[x]%1000000007;
    }
}*/
bool isPrime(ll n) {
    if (n<=1)  return false;
    if (n<=3)  return true;
    if (n%2==0||n%3==0) return false;

    for (ll i=5;i*i<=n;i=i+6)
        if (n%i==0||n%(i+2)==0)
           return false;

    return true;
}
int chek(S s,int i,int j) {
    ll cnt=0,k,a;
    fr(k,i,j) {
        //cnt=(cnt*10)+(int(s[k])-48);
        a=int(s[k])-48;
        cnt=(cnt*10)+(a);
    }
    return cnt;
}
void solve() {
 ll x;
 cin>>x;
 x++;
 ll i;
 ll cnt=0,v=0;
 if(x>1) {
     v=(((x+1)*(x))/2)-1;
     cout<<v<<endl;
 }
 v*=3;
 cnt+=v;
 v=0;
 if(x>2) {
   ll j=x-2;
   v=((j*(j+1))/2);
   cout<<v<<endl;
 }
 v*=3;
 cnt+=v;
 cnt++;
 cout<<cnt<<endl;
}
int main()
{
    dude
    //memset(arr,-1,N);
    solve();

   r0
}

#include <iostream>
#include <cmath>
using namespace std;

int main() {
	unsigned long long n,a=0,b=6, sum=1;
	cin>>n;
	if(n==0)
	{
		cout<<"1"<<endl;
	}
	else
	{
		for (int i=0; i<=n; i++)
		{
			a+=6;
		}
		if (a==b)
		{
			cout<<"7"<<endl;
		}
		else
		{
			cout<<(a+b)/2*n<<endl;
		}
	}

	return 0;
}

#include <iostream>
#include <string>
#include <locale>
#include <algorithm>
#include <cctype>
#include <math.h>
#include <cstring>
#include <stdio.h>
#include <vector>
#include <bits/stdc++.h>
#include <sstream>

using namespace std;

main(){
    unsigned long int n, i, j = 1, k = 1;

    cin >> n;

    unsigned long int a[n];

    for (int i = 0; i<n; i++){
        cin >> a[i];
   }

    i = 0;

    for(int i = 0; i<n; i++){
        if(a[i] <= a[i+1]){
            j++;
        }
        if(a[i] > a[i+1]) {
            k = max(k, j);
            j=1;
        }
    }

    cout<< k;

}
/*
    //Looping through the n
    for (int i = 0; i<n; i++){

   }
*/

#include <cstdlib>
#include<set>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
using namespace std;

int main(int argc, char** argv) {
    int n;
    cin>>n;
    cout<<((n)*(6*(n+1))/2)+1;
    return 0;
}

#include <cstdio>
typedef long long ll;

int main()
{
	int n;
	scanf("%d", &n);
	ll ans = 1 + 3 * (1+n) * n;
	printf("%lld", ans); // (a1+an) * n / 2
}

#include <bits/stdc++.h>
using namespace std;

int main() {
  long long n;
  cin >> n;
  cout << 6ll * n + 1ll;
}

#include<bits/stdc++.h>

using namespace std;

const int mx=1e5+500;

typedef long long ll;

int main()

{
    ll n;
    cin>>n;
    ll ans=6+(n)*6;
    cout<<(ans+1)<<endl;
}

#include <cstdio>
int main()
{
long long n;
scanf("%I64d",&n);
printf("%I64d",1+n*(n+1)/2*3);
return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    unsigned long long n;
    scanf("%I64d",&n);
    if(!n)
        puts("1");
    else
        printf("%I64d\n",3*n*(n+31)+1);
    return 0;
}
//2019-11-25 14:41:36.227

#include<bits/stdc++.h>

using namespace std;

int n, a;

int main(){
	cin >> n;
	for (int i = 1; i <= n; i++){
		a += i;
	}
	cout << 6 * a + 1 << endl;
	return 0;
}

#include<cstdio>
int n;
long long ans;
int main(){
	scanf("%d",&n);
	ans=3*n*(n+1)+1;
	printf("%lld",ans);
	return 0;
}

#include <iostream>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    long long int n;
    cin>>n;
    if(n==1)cout<<7;
    else cout<<n*9+1;
    return 0;
}

// no compile challenge :D
#include <bits/stdc++.h>
using namespace std;

#define testin() freopen("in.txt", "r", stdin)
#define testout() freopen("out.txt", "w", stdout)
#define logger(x) cerr << " ~~> " << #x << " = " << (x) << endl
#define loop(i, j, n) for(int (i)=(j); (i)<(n); (i)++)
#define finish(x) {cout << (x) << endl; exit(0);}
#define yy second
#define xx first
#define endl "\n"
typedef long long ll;

int hexagons(int n){
    if(n == 0)
        return 1;
    else return n*6 + hexagons(n-1);
}

int main()
{
    int n;
    cin >> n;
    cout << hexagons(n);
}

#include <iostream>
#include <cmath>
using namespace std;
typedef long long int ll;
ll result(int n){
	return pow(2*n+1,2)-n*(n+1);
}
int main(){
	long long int n;
	cin>>n;
	cout<<result(n)<<endl;
	return 0;
}

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <set>
#include <iomanip>
using namespace std;
long long n,ans=1;
int main()
{
    cin>>n;
    for(int i=0;i<n;++i)
        ans+=6*pow(2,i);
    cout<<ans;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PI 3.14
#define f first
#define mod 1000000007
#define se second
#define pb push_back
#define bs binary_search
#define vi vector < ll >
#define endl '\n'
#define forn(i, n) for (ll i = 0; i < ll(n); ++i)

void sunflower()
{
    ll n;
    cin>>n;
    ll sum=1;
    if(n==1)
    {
        cout<<1;
        return;
    }

        sum+=(3*n*(n+1));

    cout<<sum;
}
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--)
	{
	    sunflower();
	}
	return 0;
}

#include<iostream>
using namespace std;
int main(){
int n=100000,sol=0;

while(n>0){
sol+=6*n;
n--;
}sol+=1;
cout<<sol;
return 0;}

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>
#include<unordered_set>
#define sp system("pause");
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tcase ll tt; cin>>tt; while (tt--)
#define ll long long
#define in(x); { for (auto &i : x) cin >> i; }
#define out(x); { for (auto i : x) cout<<i; }
#define pb push_back
#define ve vector<ll>
#define For(i,j,k) for (int i=(int)(j);i<(int)(k);i++)
#define ritt set<int>::reverse_iterator
#define itt unordered_set<int>::iterator
#define all(x) x.begin(), x.end()
using namespace std;
void main() {
	ll a,sum=0;
	cin >> a;
	ll i = 0;
		sum += 6 + (6 * a);
	cout << sum+1;
}

#include<cstdio>
#include<cassert>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<bitset>
using namespace std;

int main()
{
    int n;
    cin >> n;
    cout << 3*n*(n+1)+1;
   return 0;
}

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(){
    int n;
    cin>>n;
    ll s=0;
    for(int i =0 ; i <= n ; i++){
        s+=(i*6)+1;
    }
    cout<<s;
    return 0;
}

#include <iostream>
#include <iomanip>
using namespace std;

int main() {
	int n;
	cin >> n;
	long long int q =3*n;
	q = q*(n + 1);
	q++;
	cout << q;
	//system("pause");
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define clr(a) memset(a, 0, sizeof(a))
#define rep(n) for(int i=0; i<n; i++)
#define repc(i, n) for(int i=0; i<n; i++)
#define rep1(n) for(int i=1; i<=n; i++)
#define repc1(i, n) for(int i=1; i<=n; i++)
#define all(v) v.begin(), v.end()
#define alla(a,n) a, a+n
#define endl "\n"
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vi;
//.............................................................

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    long n;
    cin>>n;
    ll ans = n*(12+(n-1)*6);
    ans /= 2;
    ans++;
    cout<<ans;

	return 0;
}

#include<iostream>
using namespace std;

int main(){
	unsigned long long n, ans;
	cin>>n;
	if(n==0){
		cout<<"1";
	}
	else{
		ans = (3 * n * (n+1)) + (unsigned long long)n/2;
		cout<<ans;
	}
	return 0;
}

using namespace ::std;

#define FR(a,b) for(ll a = 0; a < b; a++)
#define FRD(a,b) for(ll a = b; a >= 0; a--)
#define ll long long
#define wipe(a, b) memset(a, b, sizeof(a))
#define wipez(a) wipe(a, 0)
#include <vector>
#include <algorithm>
#include <fstream>
#include <iostream>
#include <unordered_map>
#include <string>
typedef vector<ll> vll;
typedef vector<pair<ll,ll>> vp;

bool unh(int n){
	int x = 0;
	if(n==0)return false;
	while(n!=0){
		x = n%10;
		if(x!=7&&x!=4)return false;
		n/=10;
	}
	return true;
}
ll gcd (ll a, ll b) {
	while (b) {
		a %= b;
		swap (a, b);
	}
	return a;
}
vector<char> prime;
int smpl(ll n){
prime.resize(n+1, true);
prime[0] = prime[1] = false;
for (int i=2; i<=n; ++i)
	if (prime[i])
		if (i * 1ll * i <= n)
			for (int j=i*i; j<=n; j+=i)
				prime[j] = false;
return 0;
}
const ll N = 50;
ll dp[N][N];
int main(){
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ll n;
	double a = 0;
	cin >> n;
	a = double((2+n-1)/2.0*n);
	cout << unsigned long long(a*6)+1;
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>

#define MOD 1000000007
#define inf (1 << 30)
#define LL long long
#define PI acos(-1.0)
#define eps 1e-6
using namespace std;

int dir1[8][2] = {1,2,2,1,2,-1,1,-2,-1,2,-2,1,-1,-2,-2,-1};

int dir2[4][2] = {1,0,0,1,-1,0,0,-1};

int dir3[8][2] = {1,0,0,1,-1,0,0,-1,1,1,1,-1,-1,1,-1,-1};

int gcd(int x , int y)
{
    return y == 0 ? x : gcd(y , x % y);
}

bool isPrime(int x)
{
    if(x == 1)
        return false;
    else if(x == 2)
        return true;
    for(int i = 2; i <= sqrt(x * 1.0); ++i)
    {
        if(x % i == 0)
            return false;
    }
    return true;
}

int sqr(int x)
{
    return x * x;
}

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n;
    while(~scanf("%d",&n))
    {
        if (n == 0)
        {
            cout << 0 << endl;
            continue;
        }
        else
        {
            double sum = (6 + 6 * n) * n / 2;
            printf("%.0lf\n",sum + 1);
        }
    }
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n; cin >> n;

    cout << 6 * (float(2 + (n-1))/2) * n + 1;

    return 0;
}

#include <iostream>
using namespace std;

int n;

int soch(int num) {
	return 1;
}
int main() {
	long long a;
	cin >> a;
	if (a == 0) cout << 1;
	else if (a == 1) cout << 7;
	else 	cout << 6 * (a + 1) + 1;
	return 0;
}

#include <iostream>
#include <math.h>
using namespace std;
int main(){
  unsigned int a ;
  unsigned b=0;
cin>> a;
for (int i=1;i<=a;i++){
b= (6*i)+b;
}
cout <<b+1;
}

#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <string>
using namespace std;
#define lp(a,n) for(int i=a ; i<n ; ++i)

int main() {
	int n;
	cin>>n;
	int res=0;
	while(n!=0)
	{res+=n*6;
	n--;
	}
    res++;
    cout<<res;
}

#include <bits/stdc++.h>
#define MAXN 100009
#define INF 1000000009
#define ff first
#define ss second
using namespace std;
long long int a, b;
int main()
{
	cin >> a;

	b = a * 6;
	if(a % 2 == 1)
	{
		a ++;
		b *= a / 2;
	}
	else
	{
		long long int x = b;
		b *= a / 2;
		b += x / b;
	}
	cout << b + 1 << endl;
return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    long long ans;
    if(n%2==0) ans=(n/2)*(n+1);
    else ans=((n+1)/2)*n;
    ans*=6;
    printf("%lld\n",ans+1);
    //return main();
}

#include <bits/stdc++.h>
using namespace std;
int main(){
long long n, k=1, a=0;
cin>>n;

if(n!=0){a=(n+1)*6;} else a=0;
cout<<a+1;
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>

#define MOD 1000000007
#define inf (1 << 30)
#define LL long long
#define PI acos(-1.0)
#define eps 1e-6
using namespace std;

int dir1[8][2] = {1,2,2,1,2,-1,1,-2,-1,2,-2,1,-1,-2,-2,-1};

int dir2[4][2] = {1,0,0,1,-1,0,0,-1};

int dir3[8][2] = {1,0,0,1,-1,0,0,-1,1,1,1,-1,-1,1,-1,-1};

int gcd(int x , int y)
{
    return y == 0 ? x : gcd(y , x % y);
}

bool isPrime(int x)
{
    if(x == 1)
        return false;
    else if(x == 2)
        return true;
    for(int i = 2; i <= sqrt(x * 1.0); ++i)
    {
        if(x % i == 0)
            return false;
    }
    return true;
}

int sqr(int x)
{
    return x * x;
}

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n;
    while(~scanf("%d",&n))
    {
        if (n == 0)
        {
            cout << 1 << endl;
            continue;
        }
        else
        {
            LL int sum = (6 + 6 * n) * n / 2;
            cout << sum + 1 << endl;
        }
    }
    return 0;
}

#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;
int main()
{
	int n;
    long a;
	cin>>n;
	a=6*n*(n+1);
	cout<<a/2+1;
	return 0;
}

#include <iostream>
#include <cmath>
int n;
using namespace std;

int main()
{
    cin>>n;

    cout <<  1+3*(n+1)*n<< endl;
    return 0;
}

#include <iostream>

using namespace std;

int main()
{
    long long int n;
    cin >> n;
    if (n = 0)
        cout << 0;
    else
        cout << 1 + 6 * (n - 1) + 6 * n;
    return 0;
}

#include <iostream>
using namespace std;

int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif // _DEBUG
    int n;
    cin>>n;
    long int k=(long int)6*n+3*n*(n-1)+1;
    cout<<k;
    return 0;
}

#include<stdio.h>
#include<cstring>
#include<algorithm>
#define AC main()
using namespace std;

int AC{
	long long int sum = 0;
	long long int n;
	scanf("%lld", &n);
	long long int i;
	if (n == 0)
		printf("1\n");
	else
		sum = 3 * (n + 1)*n+1;
	printf("%lld", sum);
	return 0;
}

#include<bits/stdc++.h>
using namespace std;

int main()
{
	double a;
	cin >> a ;
	cout << ((a/2)*(a+1)*6) +1 << endl;
}

#include <iostream>
#include <string>
#include <map>
#include <algorithm>
using namespace std;
int main(){
	int n;
	cin>>n;
	int sum=0,r=1;
	for (int i = 0; i <= n; i++)
	{
		sum+=r;
		r=6*(i+1);
	}
	cout<<sum<<endl;
}

#include <iostream>
using namespace std;

int main () {
	int n, sum = 1;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		sum += 6 * i;
	}
	cout << sum;
}

#include <iostream>
using namespace std;

int main(){
	int n ;
	cin >> n ;
	if ( n == 0) {
		cout << 1 ;
	}
	else {
		cout << ( ( n ) * ( n + 1 ) / 2 ) * 6 + 1 ;
	}
}

#include<bits/stdc++.h>
#define TP int
#define Max 100009
using namespace std;
inline TP read(){
    char c=getchar();
    TP x=0;
    bool f=0;
    while(!isdigit(c))f^=!(c^45),c=getchar();
    while(isdigit(c))x=(x<<1)+(x<<3)+(c^48),c=getchar();
    if(f)x=-x;return x;
}
int n=read();
int main(){
    cout<<3*n*n+3*n+1;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main()
{ int n;
cin>>n;
unsigned long z=0;
z=(3+3*n);
z=z*6;

cout<<z<<endl;
    return 0;
}

#include <iostream>
using namespace std;

int main()
{
	int n, s=0, k;
	cin>>n;
	if(n == 0)
		cout<<n<<'\n';
	k = n;
	while(n>0)
	{
		s = s + 6*n;
		n--;
	}
	if(k>0)
	cout<<s+1<<'\n';
	return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include<string>
#include<algorithm>
#include<vector>

using namespace std;

int main(){

	int n;
	cin >> n;
	int res=1;
	for (int i = 1; i <= n; i++)
	{
		res += i * 6;
	}
	cout << res << endl;
	return 0;
}

#include<stdio.h>
int main ()
{
  long long n,ans;
  scanf("%I64d",&n);
  ans=6*n+1;
  printf("%I64d\n",ans);
  return 0;
}//2018-10-15 12:19:29.315

#include <bits/stdc++.h>
using namespace std;

int main() {
    long n;
    long ans;
    cin >> n;
    ans = 6 * n * (n+1)/2 + 1;
    cout << ans;
    return 0;
}

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
   double p=1,n,i;   cin>>n;
    p+=6*(n*(n+1))/2;
     cout<< fixed << setprecision(0)<<p;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
long long n;
int main()
{
    cin>>n;
    if(n==0)
        cout<<1;
    else
        cout<<n*(6+(n-1)*3);
    return 0;
}

#include <iostream>

using namespace std;

int main(){
	long long int n;
	int p;
	cin >> n;
	p = (n + 1)*n / 2;
	n = 6 * p + 1;
		cout << n;
	return 0;
}

#include <cmath>
#include <cstdio>
#include <vector>
#include <limits>
#include <iostream>
#include <algorithm>
#include <map>
#include <iomanip>
#include <limits.h>
#define ll long long
using namespace std;

ll binpow(ll a, ll n) {
    ll res = 1.0;
    while (n) {
        if (n & 1)
            res *= a;
        a *= a;
        n >>= 1;
    }
    return res;
}
int main(){
    int n,t;
    cin>>n;
    int res=0;
    for(int i=1;i<n+1;i++){
        res+=6*i;

    }
    cout<<res;
    return 0;
}

#include<iostream>
using namespace std;
int main(){
	double n;
	int ans;
	cin>>n;
	n=(((1+n)/2)*n)*6+1;
	ans=n;
	cout<<ans;
}

#include<iostream>
using namespace std;
int n,d=1,p=1;
int main(){

	cin>>n;
	for (int i=1;i<=n;i++){
		d=6*i+p;
		p=d;
	}
	cout<<d;
}

#include <bits/stdc++.h>
#define int long long
#define mp make_pair
#define pb push_back
#define rep(i,a,n) for(int i=a;i<n;i++)
#define in insert
#define bs binary_search
#define faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
signed main()
{
    faster
    int n; cin>>n;
    int a=(n+1)*6 +1;
    cout<<a<<"\n";
    return 0;
}

#include<iostream>
using namespace std;
int main(){
	long long n;
	cin>>n;
	cout<<((((1+n)*10)/2)*n)*6/10+1;
}

#include <iostream>
#include<math.h>
using namespace std;
int main()
{
  int n , a;
  cin>>n;
  a= (6*(n+1)*(((n+3)/2)-1))+1;
  cout<<a;

  }

#include <iostream>

using namespace std;

int main()
{
   long int n;
   cin>>n;
   cout<<3*n*n+3*n+1;
    return 0;
}

#include <bits/stdc++.h>

typedef long long ll;
using namespace std;

ll n,t,a,i,j,sum,ans,k,zero;
int main()
{
    vector<ll> v;
        cin >> n;
        cout << ((n+1)*6)+1;
    return 0;
}

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cctype>
#include <cmath>

using namespace std;

long long solve(int n)
{
  long long sum = (12 + (6 * (n - 1)));
  sum *= n;
  return (sum / 2) + 1;
}

int main()
{
  int n;
  cin >> n;
  auto res = solve(n);
  cout << res << endl;
  return 0;
}

#include <iostream>

using namespace std;

int main()
{
   long int n,i; long double p=1;
   cin>>n;
    p+=6*(n*(n+1))/2;
    cout<<p;
    return 0;
}

#include<bits/stdc++.h>
#define pb push_back
using namespace std;
long long int n, cnt=1;
int main(){
    cin >> n;
    cout << n/2520;
}

#include<bits/stdc++.h>
using namespace std ;

long long n, x, ans;

int main()
{
    cin >> n ;
    ans = 7;
    x = 6 ;
    for( int i = 0 ; i < (n - 1) ; i ++ )
    {
        ans += 12 + (x - 6) * 2 ;
        x = (x - 6) * 2 + 12;
    }
    cout << ans << endl;
}

#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define pb push_back
#define ll long long int
#define w(t) int t;cin>>t; while(t--)
#define mp make_pair
#define pii pair<int,int>
#define fi first
#define se second
#define fr(n) for(int i=0;i<n;i++)
#define rep(j,n) for(int i=j;i<n;i++)
#define um unordered_map
#define M 1000000009
#define pqm priority_queue <int, vector<int>, greater<int> >
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll s=0;
    fr(n+1){
    	if(n>=2)
    	s+=6;
	}
	if(n==1){
		s=6;
	}
	s++;
	cout<<s<<endl;
	return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include<string>
#include<algorithm>
#include<vector>

using namespace std;
int main(){

	long long  n,res=1;

	for (int i = 1; i <= n; i++)
	{
		res += i * 6;
	}
	cout << res << endl;
	return 0;
}

#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	n=((((1+n)*10)/2)*n)*6/10+1;
	cout<<n;
}

#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;

#define  Infile         freopen("input.txt", "r", stdin)
#define  Outfile        freopen("output.txt", "w", stdout)
#define  show(a)        cerr<<"\n-> "<<#a<<" = "<<a<<endl
#define  fu(i,a,b)      for(ll i=(a); i<=ll(b);++i)
#define  fd(i,a,b)      for(ll i=(a); i>=ll(b);--i)
#define  fo(i,n)        for(ll i=0; i<ll(n);++i)
#define  grter(u)       u,vector<u>,greater<u>
#define  fixset(x)      fixed<<setprecision(x)
#define  ms(a, x)       memset(a,x,sizeof(a))
#define  all(x)         (x).begin(),(x).end()
#define  mp(a,b)        make_pair(a,b)
#define  pb(x)          push_back(x)
#define  pr(a)          cout<<a<<endl
#define  prs(a)         cout<<a<<" "
#define  ar(x, n)       (x),(x)+(n)
#define  _              <<", "<<
#define  fii            first
#define  see            second
#define  endl           '\n'

typedef double db;
typedef long long ll;
typedef vector <ll> vii;
typedef pair <ll, ll> pll;

clock_t TimeBegin, TimeEnd;
ll LX[] = {-1,0,0,1,-1,-1,1,1}; // 4 - 8
ll LY[] = {0,-1,1,0,-1,1,-1,1};
ll const INF = 1e18;
db const EPS  = DBL_EPSILON;

inline void Tstop();
inline void Tstart();
inline ll eulerPhi(ll NUM);
inline ll mnmize(ll& a,ll b);
inline ll mxmize(ll& a,ll b);
inline ll mod(string NUM, ll BASE);
inline ll fpow(ll Aa, ll Ax, ll BASE);
inline ll diMod(ll Aa, ll Bb, ll BASE);
inline ll mulMod(ll Aa, ll Bb, ll BASE);
inline string toString(ll NUM);

//Declare Here
ll n;

//============//

void Solve()
{
    //code here
    cin >> n;
    if (n == 0) cout << 1;
    else cout << (n+1)*(n*2+2)+1;

}

//=============================================================================//

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    #ifdef RAVENCLAW
        Tstart();
        //Infile;
        //Outfile;
    #endif
        Solve();
        Tstop();
    return 0;
}

//=============================================================================//
//=============================================================================//

inline ll mod(string NUM, ll BASE)
{
    ll RES = 0;
    fo(i, NUM.length())
        RES = (RES*10 + (ll)NUM[i] - '0') % BASE;
    return RES;
}

ll fpow(ll Aa, ll Xx, ll BASE)
{
    ll res = 1;
    ll temp = Aa%BASE;
    while(Xx > 0)
    {
        if (Xx&1)
            res = (res*temp)%BASE;
        Xx >>= 1;
        temp = (temp*temp)%BASE;
    }
    return res;
}

inline ll diMod(ll Aa, ll Bb, ll BASE)
{
    //(A/B)%Base
    ll result = (Aa * fpow(Bb, BASE-2, BASE)) % BASE;
    return result;
}

inline ll mulMod(ll Aa, ll Bb, ll BASE)
{
    Aa %= BASE;
    Bb %= BASE;
    ll Qq = ((long double)Bb / BASE)*Aa;
    ll Rr = Aa * Bb - Qq * BASE;
    return (Rr % BASE + BASE) % BASE;
}

inline ll eulerPhi(ll NUM)   // O(sqrt(n))
{
    if (NUM == 0)
        return 0;
    ll RESULT = NUM;
    for (ll TMPX = 2; TMPX*TMPX <= NUM; ++TMPX)
    {
        if (NUM % TMPX == 0)
        {
            RESULT -= RESULT / TMPX;
            while (NUM % TMPX == 0)
                NUM /= TMPX;
        }
    }
    if (NUM > 1) RESULT -= RESULT / NUM;
        return RESULT;
}

inline string toString(ll NUM)
{
    stringstream sss; sss << NUM;
    return sss.str();
}

inline ll mnmize(ll& a,ll b)
{
    return a = (a > b ? b : a);
}

inline ll mxmize(ll& a,ll b)
{
    return a = (a < b ? b : a);
}

inline void Tstart()
{
    TimeBegin = clock();
}

inline void Tstop()
{
    #ifdef RAVENCLAW
    TimeEnd = clock();
    cout << "\nTime elapsed: " << 1000 * (TimeEnd - TimeBegin) / CLOCKS_PER_SEC << " ms\n";
    #endif
}

#include <iostream>
#include<math.h>
using namespace std;
int main()
{
  int n , a;
  cin>>n;
  a= ((6*(n+2)*(n+1)/2)-(6*(n+1)))+1;
  cout<<a;
  }