#Lutece0933. The minimum square sum

The minimum square sum

Migrated from Lutece 933 The minimum square sum

All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.

Description

Given a prime p(p<108)p (p<10^8),you are to find min{x2+y2x^2+y^2},where xx and yy belongs to positive integer, so that (x2+y2)0(x^2+y^2) \equiv 0 (mod pp).

Input

Every line is a pp. No more than 1000110001 test cases.

Output

The minimum square sum as described above.

Samples

输入数据 1

2
3
5

输出数据 1

2
18
5

Resources

2011 Heilongjiang collegiate programming contest