#include <bits/stdc++.h>
using namespace std;
long long n;
long long sum(long long a) { return 1LL * (a + a * a) / 2; }
int main() {
  scanf("%I64d", &n);
  printf("%I64d\n", 1LL * sum(n) * 6 + 1);
  return 0;
}
