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