GCDDCG

시간 제한1초메모리 제한2048 MB

요약
각 i에 대해 두 카드 집합의 최대공약수가 모두 i가 되도록 서로소인 공집합 아닌 두 집합을 만드는 경우의 수를 세고, 그 수에 i를 곱한 값을 모두 더해 998244353으로 나눈 나머지를 구한다.
난이도

어려움10점 중 8점

유형
수학, 정수론, 조합론, 동적 계획법
정답자
아직 제출이 없습니다

문제

You are playing the Greatest Common Divisor Deck-Building Card Game (GCDDCG). There are NN cards (numbered from 11 to NN). Card ii has the value of A_iA\_i, which is an integer between 11 and NN (inclusive).

The game consists of NN rounds (numbered from 11 to NN). Within each round, you need to build two non-empty decks, deck 11 and deck 22. A card cannot be inside both decks, and it is allowed to not use all NN cards. In round ii, the greatest common divisor (GCD) of the card values in each deck must equal ii.

Your creativity point during round ii is the product of ii and the number of ways to build two valid decks. Two ways are considered different if one of the decks contains different cards.

Find the sum of creativity points across all NN rounds. Since the sum can be very large, calculate the sum modulo 998,244,353998\\, 244\\, 353.

입력

The first line consists of an integer NN (2≤N≤200,0002 ≤ N ≤ 200\\, 000).

The second line consists of NN integers A_iA\_i (1≤A_i≤N1 ≤ A\_i ≤ N).

출력

Output a single integer representing the sum of creativity points across all NN rounds modulo 998,244,353998\\, 244\\, 353.

예제3

  1. 예제 1

    입력
    3
    3 3 3
    
    예상 출력
    36
    
  2. 예제 2

    입력
    4
    2 2 4 4
    
    예상 출력
    44
    
  3. 예제 3

    입력
    9
    4 2 6 9 7 7 7 3 3
    
    예상 출력
    10858