/* * VIVA - vanb's Input Verification Assistant * (C) 2012-2020 * * @author vanb */ import java.io.PrintStream; import java.util.Arrays; import java.util.Scanner; /** * Solution to The n Days of Christmas. * * @author vanb */ public class ndays_vanb { /** Input. */ private static Scanner sc; /** Output. */ private static PrintStream ps; /** The Constant MOD. */ private static final long MOD = 998244353L; /** The Constant INV2, the mod inverse of 2. */ private static final long INV2 = (MOD+1L)/2L; /** The Constant INV3, the mod inverse of 3. */ private static final long INV3 = (MOD+1L)/3L; /** * The Class ModNum. * * @author vanb */ private class ModNum { /** The value. */ public long value; /** * Instantiates a new mod num. * * @param value the value */ public ModNum( long value ) { this.value = value % MOD; } /** * Add a value to this one. * * @param other the other value * @return the new ModNum, the sum of this+other */ public ModNum plus( long other ) { return new ModNum( (value+other%MOD) % MOD ); } /** * Add a ModNum to this one. * * @param other the other ModNum * @return the new ModNum, the sum of this+other */ public ModNum plus( ModNum other ) { return new ModNum( (value+other.value) % MOD ); } /** * Multiply this ModNum by a value. * * @param other the other value * @return the new ModNum, the product of this*other */ public ModNum times( long other ) { return new ModNum( (other%MOD)*value % MOD ); } /** * Multiply this ModNum by another ModNum. * * @param other the other ModNum * @return the new ModNum, the product of this*other */ public ModNum times( ModNum other ) { return new ModNum( (value*other.value) % MOD ); } } /** * Do it!. */ private void doit() { ModNum k = new ModNum(sc.nextLong()); ModNum a = k.times( 2L ).plus( 1L ).times( INV3 ).plus( 1L ); ModNum b = k.plus( 1L ).times( k ).times( INV2 ); ModNum answer = a.times( b ).times( INV2 ); ps.println( answer.value ); } /** * Main. * * @param args unused * @throws Exception the exception */ public static void main( String[] args ) throws Exception { sc = new Scanner( System.in ); ps = System.out; new ndays_vanb().doit(); } }