{"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":"\u003cp\u003e You are given an array $$$a_1, a_2, \\dots, a_n$$$ where all $$$a_i$$$ are integers and greater than $$$0$$$.\u003c/p\u003e\u003cp\u003e In one operation, you can choose two different indices $$$i$$$ and $$$j$$$ ($$$1 \\le i, j \\le n$$$). If $$$gcd(a_i, a_j)$$$ is equal to the minimum element of $$$a$$$, you can swap $$$a_i$$$ and $$$a_j$$$. $$$gcd(x, y)$$$ denotes the \u003ca href\u003d\"https://en.wikipedia.org/wiki/Greatest_common_divisor\"\u003egreatest common divisor (GCD)\u003c/a\u003e of integers $$$x$$$ and $$$y$$$.\u003c/p\u003e\u003cp\u003e Now you\u0027d like to make $$$a$$$ non-decreasing using the operation any number of times (possibly zero). Determine if you can do this.\u003c/p\u003e\u003cp\u003e An array $$$a$$$ is non-decreasing if and only if $$$a_1 \\le a_2 \\le \\ldots \\le a_n$$$.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003e The first line contains one integer $$$t$$$ ($$$1 \\le t \\le 10^4$$$)\u0026nbsp;— the number of test cases.\u003c/p\u003e\u003cp\u003e The first line of each test case contains one integer $$$n$$$ ($$$1 \\le n \\le 10^5$$$)\u0026nbsp;— the length of array $$$a$$$.\u003c/p\u003e\u003cp\u003e The second line of each test case contains $$$n$$$ positive integers $$$a_1, a_2, \\ldots a_n$$$ ($$$1 \\le a_i \\le 10^9$$$)\u0026nbsp;— the array itself.\u003c/p\u003e\u003cp\u003e It is guaranteed that the sum of $$$n$$$ over all test cases doesn\u0027t exceed $$$10^5$$$.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003e For each test case, output \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eYES\u003c/span\u003e\" if it is possible to make the array $$$a$$$ non-decreasing using the described operation, or \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eNO\u003c/span\u003e\" if it is impossible to do so.\u003c/p\u003e"}},{"title":"Sample 1","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e4\n1\n8\n6\n4 3 6 6 2 9\n4\n4 5 6 7\n5\n7 5 2 2 4\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eYES\nYES\nYES\nNO\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Note","value":{"format":"HTML","content":"\u003cp\u003e In the first and third sample, the array is already non-decreasing.\u003c/p\u003e\u003cp\u003e In the second sample, we can swap $$$a_1$$$ and $$$a_3$$$ first, and swap $$$a_1$$$ and $$$a_5$$$ second to make the array non-decreasing.\u003c/p\u003e\u003cp\u003e In the forth sample, we cannot the array non-decreasing using the operation.\u003c/p\u003e"}}]}