{"problem":{"name":"Adjacent GCD","description":{"content":"Define the **score** of a sequence of positive integers $B = (B_1, B_2, \\dots, B_k)$ as $\\displaystyle \\sum_{i=1}^{k-1} \\gcd(B_i, B_{i+1})$.   Given a sequence of positive integers $A = (A_1, A_2, \\do","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"arc185_e"},"statements":[{"statement_type":"Markdown","content":"Define the **score** of a sequence of positive integers $B = (B_1, B_2, \\dots, B_k)$ as $\\displaystyle \\sum_{i=1}^{k-1} \\gcd(B_i, B_{i+1})$.  \nGiven a sequence of positive integers $A = (A_1, A_2, \\dots, A_N)$, solve the following problem for $m = 1, 2, \\dots, N$.\n\n*   There are $2^m - 1$ non-empty subsequences of the sequence $(A_1, A_2, \\dots, A_m)$. Find the sum of the scores of all those subsequences, modulo $998244353$. Two subsequences are distinguished if they are taken from different positions in the sequence, even if they coincide as sequences.\n\n## Constraints\n\n*   $1 \\leq N \\leq 5 \\times 10^5$\n*   $1 \\leq A_i \\leq 10^5$\n*   All input values are integers.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$N$\n$A_1$ $A_2$ $\\dots$ $A_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"arc185_e","tags":[],"sample_group":[["3\n9 6 4","0\n3\n11\n\nConsider the case $m = 3$. Here are the non-empty subsequences of $(A_1, A_2, A_3) = (9, 6, 4)$ and their scores.\n\n*   $(9)$: Score is $0$.\n*   $(6)$: Score is $0$.\n*   $(4)$: Score is $0$.\n*   $(9, 6)$: Score is $\\gcd(9, 6) = 3$.\n*   $(9, 4)$: Score is $\\gcd(9, 4) = 1$.\n*   $(6, 4)$: Score is $\\gcd(6, 4) = 2$.\n*   $(9, 6, 4)$: Score is $\\gcd(9, 6) + \\gcd(6, 4) = 3 + 2 = 5$.\n\nTherefore, the answer for $m = 3$ is $0 + 0 + 0 + 3 + 1 + 2 + 5 = 11$."],["5\n3 8 12 6 9","0\n1\n13\n57\n155"],["10\n47718 21994 74148 76721 98917 73766 29598 59035 69293 29127","0\n2\n14\n35\n97\n372\n866\n1859\n4273\n43287"]],"created_at":"2026-03-03 11:01:13"}}