#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const double c = 11 * 1e-9;
void solve(int n) {
  int m = 0, x, y, i, j, b, k, z, l, r, xx, t = 0;
  long long int a = n;
  a = a * (a + 1) * 3 + 1;
  printf("%I64d", a);
}
int main() {
  int n, m, x, y, i, j, q = 0;
  while (scanf("%d", &n) != EOF) {
    solve(n);
    printf("\n");
  }
  return 0;
}
