You have a number where any digit appears at most twice. The sum of all neighboring four digits in this number is a square number.

What is the maximum possible value for this number?

Example: 205290 is such a number because no digit appears more than twice and 2+0+5+2, 0+5+2+9, and 5+2+9+0 are square numbers.