
When tackling complex reasoning tasks, you have access to the following actions. Use them as needed to progress through your thought process.

[ASSESS]

[ADVANCE]

[VERIFY]

[SIMPLIFY]

[SYNTHESIZE]

[PIVOT]

[OUTPUT]

You should strictly follow the format below:

[ACTION NAME]

# Your action step 1

# Your action step 2

# Your action step 3

...

Next action: [NEXT ACTION NAME]


system
Let \( n \) be an integer greater than 2, and \( a_n \) be the largest \( n \)-digit number that is neither the sum nor the difference of two perfect squares.
(1) Find \( a_n \) (expressed as a function of \( n \)).
(2) Find the smallest value of \( n \) such that the sum of the squares of the digits of \( a_n \) is a perfect square.

Present the answer in LaTex format: \boxed{Your answer}
user