{"trustable":false,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"B-Doin\u0027 Time\u003cp\u003eOne day, Fop_zz is playing a boring game \u003cspan class\u003d\"tex-font-style-it\"\u003emerge numbers\u003c/span\u003e though he is busy.\u003c/p\u003e\n\u003cp\u003eThere is a sequence $$$\\{a_i\\}$$$ of length $$$N$$$ and he should play this game for $$$n-1$$$ turns. In one turn, he chooses an index $$$x$$$ and then he merges $$$a_x$$$ and $$$a_{x+1}$$$ to $$$a_x \\times a_{x+1} \\bmod 1\\,000\\,003$$$ and gets $$$(a_x-a_{x+1})^2$$$ scores. \u003c/p\u003e\n\u003cp\u003eSo, after one turn, the length of sequence will decrease exactly one, and after the last turn there\u0027s only $$$1$$$ integer in the sequence and he stops.\u003c/p\u003e\n\u003cp\u003eNow he want to know the maximum total scores he can get. Can you help him?\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line contains one integer $$$N ~ (1 \\leq N \\leq 300)$$$ denoting the length of sequence.\u003c/p\u003e\n\u003cp\u003eThe second line contains $$$N$$$ integers $$$a_1, a_2, \\cdots, a_n ~ (1 \\leq a_i \\leq 10^6)$$$.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eOutput one line with only one integer denoting the answer.\u003c/p\u003e"}},{"title":"Example","value":{"format":"HTML","content":"\u003cdiv class\u003d\"sample-test\"\u003e\n \u003cdiv class\u003d\"input\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Input\n \u003c/div\u003e\n \u003cpre\u003e3\n1 2 3\n\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"output\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Output\n \u003c/div\u003e\n \u003cpre\u003e26\n\u003c/pre\u003e\n \u003c/div\u003e\n\u003c/div\u003e"}}]}