#include <bits/stdc++.h>
using namespace std;
namespace jumpmelon {
const int MAXN = 1000000;
int Q[MAXN + 1];
void work() {
  int n;
  long long k;
  scanf("%d%lld", &n, &k);
  for (int i = 1; i <= n; i++) k -= i;
  for (int i = 1, p = n, j = n; i <= j; i++) {
    while (i <= j && k + i < max(i, p)) Q[j--] = p--;
    if (i <= j) {
      k += i - max(i, p);
      Q[i] = p--;
    }
  }
  if (k < 0)
    puts("-1");
  else {
    long long s = 0;
    for (int i = 1; i <= n; i++) s += max(i, Q[i]);
    printf("%lld\n", s);
    for (int i = 1; i <= n; i++) printf("%d ", i);
    putchar('\n');
    for (int i = 1; i <= n; i++) printf("%d ", Q[i]);
    putchar('\n');
  }
}
}  // namespace jumpmelon
int main() {
  jumpmelon::work();
  return 0;
}
