Rectangle Cutting

From CSES. Cut rectangle into squares DP. Solve the geometry problem "Rectangle Cutting".

Examples
Input: [1,2,3]
Output: 0
Hints

Rectangle Cutting

**From CSES.** Cut rectangle into squares DP. Solve the geometry problem "Rectangle Cutting".