[Question]
  [
This is a sequence question of the usual type, as applied to [OEIS sequence A038666](https://oeis.org/A038666). That is, do either of the following:
* Accept no or any input, and output A038666 until the heat death of the universe.
* Accept a positive integer as input, and output the \$n\$th term of A038666 or its first \$n\$ terms. (If using \$0\$- instead of \$1\$-indexing, then of course you also have to output `1` on `0` input.)
The \$n\$th term of A038666 is the least area among rectangles that contain non-overlapping squares of sizes \$1\times1,2\times2,\dots n\times n\$ if you're using \$1\$-indexing.
### Example:
The smallest-area rectangle which can contain non-overlapping squares of sizes \$1\times1\$ through \$4\times4\$ has dimensions \$7\times5\$:
```
4 4 4 4 3 3 3
4 4 4 4 3 3 3
4 4 4 4 3 3 3
4 4 4 4 2 2 1
x x x x 2 2 x
```
Therefore, \$a(4)=7\times5=35\$ (\$1\$-indexed).
Similarly, the least-area rectangle containing non-overlapping squares of sizes \$1\times1\$ through \$17\times17\$ [has dimensions \$39\times46\$](http://web.archive.org/web/20190218045512/http://www.mathpuzzle.com/17sqrsrect.gif), so \$a(17)=39\times46=1794\$ (\$1\$-indexed).
  
[Answer]
# JavaScript (ES6), 172 bytes
*Slower but shorter version suggestion suggested by @JonathanAllan (also saving 4 bytes in the original answer):*
```
f=(n,A,S=(n,c)=>n>=0?c(n)||S(n-1,c):0)=>S(A,w=>(F=(l,n)=>n?S(w-n,x=>S(A/w-n,y=>l.some(([X,Y,W])=>X<x+n&X+W>x&Y<y+n&Y+W>y)?0:F([...l,[x,y,n]],n-1))):A%w<1)([],n))?A:f(n,-~A)
```
[Try it online!](https://tio.run/##HY5BboNADEX3OcUs0sgWZgrLUgY0m1yARUAIKYhA1Yp6qlAVEKFXp6ar//X8LPuj/qmH5v7@9e2zu7Xb1hlgspTt0aBJODFB2gDj45EB@6HAKBCegaXRJHA20BPvYprB6DNN/7Pnvc4m6fXgPluAMqeCLpV4eTx5fMq9SzKdiniWXkifMQ2iM5Ra657KiWbiqiK5h4iRfRrjEKEUgJjaqJPf/F@LW@fuwMqo8FWxitWLhOehWg5KNY4H17e6d29wreG48IpiHhdZxvWKh3X7Aw "JavaScript (Node.js) – Try It Online")
---
# Original answer, ~~209 183 178~~ 174 bytes
Returns the \$N\$th term of the sequence, 1-indexed.
```
f=(n,A,S=(n,c)=>n>=0?c(n)||S(n-1,c):0)=>S(A,w=>A%w?0:(F=(l,n)=>n?S(w-n,x=>S(A/w-n,y=>l.some(([X,Y,W])=>X<x+n&X+W>x&Y<y+n&Y+W>y)?0:F([...l,[x,y,n]],n-1))):1)([],n))?A:f(n,-~A)
```
[Try it online!](https://tio.run/##HY7BboNADETv@Yo9pJEtzBaulAVxyQ9wCAghBVGoGm28VagKiNBfp6anGY@ePb41P83QPj6/vn1279229QaYMsp3adEknJggbYHx@cyB/VDCKJA8h4xGk2QvYxpEcDZgiXc8zWH0maZ/4nW3s0msHty9A6gKKulSC1fEk8enwrsk06mMZ/Gl@Bnl2BkqrbWlaqKZuK5JWhExChEqGRDTLOrlO/83w613D2BlVPimWMUqDEQ9D9VyUKp1PDjbaes@4NrAceEVBT0uso3rFQ/r9gc "JavaScript (Node.js) – Try It Online")
## Commented
### Helper function
We first define a helper function \$S\$ which invokes a callback function \$c\$ for \$n\$ to \$0\$ (both included) and stops as soon as a call returns a truthy value.
```
S = (n, c) =>               // n = integer, c = callback function
  n >= 0 ?                  // if n is greater than or equal to 0:
    c(n) ||                 //   invoke c with n; stop if it's truthy
    S(n - 1, c)             //   or go on with n - 1 if it's falsy
  :                         // else:
    0                       //   stop recursion and return 0
```
### Main function
We start with \$A=1\$.
For each pair \$(w,h)\$ such that \$w\times h = A\$, we try to insert all squares of size \$1\times1\$ to \$n\times n\$ (actually starting with the largest one) in the corresponding area, in such a way that they don't overlap with each other.
We keep track of the list of squares with their position \$(X,Y)\$ and their width \$W\$ in \$l[\text{ }]\$.
We either return \$A\$ if a valid arrangement was found, or try again with \$A+1\$.
```
f = ( n,                    // n = input
      A ) =>                // A = candidate area (initially undefined)
S(A, w =>                   // for w = A to w = 0:
  A % w ?                   //   if w is not a divisor of A:
    0                       //     do nothing
  : (                       //   else:
    F = (l, n) =>           //     F = recursive function taking a list l[] and a size n
      n ?                   //       if n is not equal to 0:
        S(w - n, x =>       //         for x = w - n to x = 0
          S(A / w - n, y => //           for y = A / w - n to y = 0:
            l.some(         //             for each square in l[]
            ([X, Y, W]) =>  //             located at (X, Y) and of width W:
              X < x + n &   //               test whether this square is overlapping
              X + W > x &   //               with the new square of width n that we're
              Y < y + n &   //               trying to insert at (x, y)
              Y + W > y     //
            ) ?             //             if some existing square does overlap:
              0             //               abort
            :               //             else:
              F([ ...l,     //               recursive call to F:
                  [x, y, n] //                 append the new square to l[]
                ],          //
                n - 1       //                 and decrement n
              )             //               end of recursive call
          )                 //           end of iteration over y
        )                   //         end of iteration over x
      :                     //       else (n = 0):
        1                   //         success: stop recursion and return 1
    )([], n)                //     initial call to F with an empty list of squares
) ?                         // end of iteration over w; if it was successful:
  A                         //   return A
:                           // else:
  f(n, -~A)                 //   try again with A + 1
```
[Answer]
# [Python 2 (PyPy)](http://pypy.org/), ~~250~~ 236 bytes
-14 bytes thanks to [msh210](https://codegolf.stackexchange.com/users/1976/msh210)'s suggestions.
Outputs the 1-indexed nth term of the sequence.
```
n=input()
r=range
k=n*-~n*(n-~n)/6
m=k*k
for Q in r(m):
 P={0}
 for X in r(n,0,-1):P|=([x for x in[{(x+a,y+b)for a in r(X)for b in r(X)}for x in r(Q%k-X+1)for y in r(Q/k-X+1)]if not x&P]+[{0}])[0]
 if len(P)>k:m=min(Q%k*(Q/k),m)
print m
```
[Try it online!](https://tio.run/##NY7LCoMwEEX3@YrZtGR8oJbShZB@g@4EcWGhj5BmDMGCwdpft1HbzcA998wwxvWPjg6xccbNMwlJ5tVzZFbYlu5XpgQF8YcCTn5icmJaqECxW2ehBElgucacQSHGdGKw4GrDFKVRnGFevAWvh7UZfFOPfAjbyIUXXFC7ydUaLv8w/W2fyp2KqzBbBfdDyYYaeQPqehj2RRPW/oEG67Rh4PHzSrzAs8q10JKWI8GyhpFGZqykHvQ8H78 "Python 2 (PyPy) – Try It Online") For n>4, this takes lot of time. I have verified the result up to n=7 locally.
]