import java.io.PrintWriter
import java.util.*
import kotlin.math.max
import kotlin.math.pow

@JvmField
    val INPUT = System.`in`!!
    @JvmField
    val OUTPUT = System.out!!

    @JvmField
    val reader = INPUT.bufferedReader()

    fun readLine(): String? = reader.readLine()
    fun readLn() = reader.readLine()!!
    @JvmField
    var tokenizer: StringTokenizer = StringTokenizer("")

    fun read(): String {
        while (tokenizer.hasMoreTokens().not()) tokenizer = StringTokenizer(reader.readLine() ?: return "", " ")
        return tokenizer.nextToken()
    }

    fun readInt() = read().toInt()
    fun readDouble() = read().toDouble()
    fun readLong() = read().toLong()
    fun readIntArray(n: Int) = IntArray(n) { read().toInt() }
    fun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }
    fun readLongArray(n: Int) = LongArray(n) { read().toLong() }

    @JvmField
    val rw = PrintWriter(OUTPUT, false)

    inline fun output(block: PrintWriter.() -> Unit) {
        rw.apply(block).flush()
    }

    fun printLArray(a: LongArray) { a.forEach { x -> rw.print(x); rw.print(" ") };rw.println() }
    fun printIArray(a: IntArray) { a.forEach { x -> rw.print(x);rw.print(" ") };rw.println() }

    private var is_prime: BooleanArray? = null
    private var prime: ArrayList<Int>? = null
    fun sieve(n: Int) {
        is_prime = BooleanArray(n + 10)
        prime = ArrayList()
        for (i in 2..n) is_prime!![i] = true
        for (i in 2..n) {
            if (is_prime!![i]) prime!!.add(i)
            var j = 0
            while (j < prime!!.size && i * prime!![j] < n) {
                is_prime!![i * prime!![j]] = false
                if (i % prime!![j] == 0) break
                ++j
            }
        }
    }

    fun mergeSort(a: IntArray) {
        val n = a.size
        if (n < 2) return
        val mid = n / 2; val left = IntArray(mid); val right = IntArray(n - mid)
        for (i in 0 until mid) left[i] = a[i]
        for (i in mid until n) right[i - mid] = a[i]
        mergeSort(left);mergeSort(right);merge(left, right, a)
    }

    fun merge(left: IntArray, right: IntArray, a: IntArray) {
        val nLeft = left.size; val nRight = right.size
        var i = 0; var j = 0; var k = 0
        while (i < nLeft && j < nRight) {
            if (left[i] <= right[j]) {
                a[k] = left[i];k++;i++
            } else {
                a[k] = right[j]; k++;j++
            }
        }
        while (i < nLeft) {a[k] = left[i]; i++; k++}
        while (j < nRight){a[k] = right[j]; j++; k++}
    }

    fun gcd(a: Long, b: Long): Long {
        if (b == 0L) return a
        return gcd(b, a % b)
    }

    fun smallest(a: IntArray): Int {
        var min = a[0]
        for (i in 1 until a.size) {
            if (a[i] < min) min = a[i]
        }
        return min
    }
fun main(){

    val n = readInt()
    val dp = IntArray(n)
    dp[0] = 1
    for (i in 1 until n)  dp[i] = dp[i - 1] + 4*i
    rw.println(dp[n-1])
    rw.close()
}


fun main(args: Array<String>) {

    val n = readLine()!!.toInt()

    var a_n = 1
    for (i in 2..n) {
        a_n += 4 * (i-1)
    }

    println(a_n)
}


import java.util.*
fun main(args: Array<String>) {var reader= Scanner(System.`in`)
    var n = reader.nextInt()
    print( 2*(n)*(n-1) + 1)
}


fun main() {
    val (n, k) = readInts()

    val ans = (0 until n).binarySearch { x ->
        k.compareTo((n - x).toLong() * (n - x + 1) / 2 - x)
    }.value

    println(ans)
}

fun IntRange.binarySearch(signumFunc: (Int) -> Int): BinarySearchResult<Int> {
    var low = start
    var high = endInclusive

    while (low <= high) {
        val mid = low / 2 + high / 2 + (low % 2 + high % 2) / 2
        val cmp = signumFunc(mid)

        if (cmp < 0)
            low = mid + 1
        else if (cmp > 0)
            high = mid - 1
        else
            return BinarySearchResult(mid, true) // key found
    }
    return BinarySearchResult(low, false)  // key not found
}
data class BinarySearchResult<out T>(val value: T, val exactFound: Boolean)

fun readLn() = readLine()!!
fun readInt() = readLn().toInt()
fun readDouble() = readLn().toDouble()
fun readLong() = readLn().toLong()
fun readStrings() = readLn().split(' ')
fun readInts() = readStrings().map { it.toInt() }
fun readDoubles() = readStrings().map { it.toDouble() }
fun readLongs() = readStrings().map { it.toLong() }

class Output {
    private val sb = StringBuilder()
    fun print(o: Any?) { sb.append(o) }
    fun println() { sb.append('\n') }
    fun println(o: Any?) { sb.append(o).append('\n') }
    @JvmName("_print") fun Any?.print() = print(this)
    @JvmName("_println") fun Any?.println() = println(this)
    fun nowPrint() { kotlin.io.print(sb) }
}
inline fun output(block: Output.()->Unit)
    { Output().apply(block).nowPrint() }


fun main() {
    val r = System.`in`.bufferedReader()
    val s1 = StringBuilder()
    //val n = r.readLine()!!.toLong()
    //val v = r.readLine()!!.split("").filter { it.isNotEmpty() }
    fun put(l:Long) = (1+l)*l/2
    fun eat(l:Long) = l
    val (action, remain) = r.readLine()!!.split(" ").map { it.toLong() }
    fun inbox(l:Long) = put(l)-eat(action-l)
    fun s(x:Long):Long{
        var le = 0L
        var ri = action+1
        while (le<ri){
            val mi = le+(ri-le)/2
            when{
                inbox(mi)<x -> le = mi+1
                inbox(mi)>x -> ri = mi
                inbox(mi) == x -> return mi
            }
        }
        return -1
    }
    val ans = s(remain)
    println(action-ans)
    /*repeat(r.readLine()!!.toInt()) {
        //val len = r.readLine()!!.toInt()
        val (n, s, t) = r.readLine()!!.split(" ").map { it.toLong() }
        val more = s+t-n
        println(minOf(n- minOf(s, t)+1, maxOf(s, t)+1))
    }*/
}


import kotlin.math.roundToInt
import kotlin.math.sqrt

fun main() {
    val (n, k) = readDoubles()

    val disc = sqrt(8*(n + k) + 9)
    val pr = 2*n + 3

    val ans = (if(disc <= pr) (pr - disc)/2 else (pr + disc)/2).toInt()

    println(ans)
}

fun readLn() = readLine()!!
fun readInt() = readLn().toInt()
fun readDouble() = readLn().toDouble()
fun readLong() = readLn().toLong()
fun readStrings() = readLn().split(' ')
fun readInts() = readStrings().map { it.toInt() }
fun readDoubles() = readStrings().map { it.toDouble() }
fun readLongs() = readStrings().map { it.toLong() }

class Output {
    private val sb = StringBuilder()
    fun print(o: Any?) { sb.append(o) }
    fun println() { sb.append('\n') }
    fun println(o: Any?) { sb.append(o).append('\n') }
    @JvmName("_print") fun Any?.print() = print(this)
    @JvmName("_println") fun Any?.println() = println(this)
    fun nowPrint() { kotlin.io.print(sb) }
}
inline fun output(block: Output.()->Unit)
    { Output().apply(block).nowPrint() }


import java.lang.IllegalArgumentException

private fun readString() = readLine()!!
private fun readInt() = readString().toInt()
private fun readStrings() = readString().split(" ")
private fun readInts() = readStrings().map { it.toInt() }

fun sportMafia(moves: Long, candiesLeft: Long): Int {
    var left = 0L
    var right = moves
    while (left <= right) {
        val current = left + (right - left) / 2
        val broughtIn = sumOf(current)
        val eaten = moves - current
        val resultingCandies = broughtIn - eaten
        when {
            resultingCandies < candiesLeft -> {
                left = current + 1
            }
            resultingCandies == candiesLeft -> return eaten.toInt()
            resultingCandies > candiesLeft -> {
                right = current - 1
            }
        }
    }
    throw IllegalArgumentException("solution not found")
}

fun sumOf(willAdd: Long): Long = (willAdd * (willAdd + 1)) / 2

fun main() {
    val (moves, candiesLeft) = readInts()
    println(sportMafia(moves.toLong(), candiesLeft.toLong()))
}


import kotlin.math.max

fun score(p: Int, c: Int, x: Int) : Int {
  return max(0, p-c*x)
}

fun main(args: Array<String>) {
  val (n, c) = readLine()!!.split(" ").map(String::toInt)
  val p = readLine()!!.split(" ").map(String::toInt)
  val t = readLine()!!.split(" ").map(String::toInt)
  var (score_limak, score_radewoosh) = listOf(0, 0)
  var (time_limak, time_radewoosh) = listOf(0, 0)
  for(i in 0..n-1) {
    time_limak += t[i]
    score_limak += score(p[i], c, time_limak)
  }
  for(i in n-1 downTo 0) {
    time_radewoosh += t[i]
    score_radewoosh += score(p[i], c, time_radewoosh)
  }
  if(score_radewoosh == score_limak) println("Tie")
  else if(score_radewoosh > score_limak) println("Radewoosh")
  else println("Limak")
}


fun main(args: Array<String>){
	var tmpTime = 0
	var Limak = 0
	var Radewoosh = 0

	val (N,c) = readLine()!!.split(' ')

	val points = readLine()!!.split(' ').map { it.toInt() }
	val time = readLine()!!.split(' ').map { it.toInt() }

	for(i in 0 until N.toInt()){
		tmpTime += time[i]
		if(points[i]-tmpTime*c.toInt() < 0){
			continue
		}else{
			Limak += points[i]-tmpTime*c.toInt()
		}
	}
	tmpTime = 0
	for(i in N.toInt()-1 downTo 0){
		tmpTime += time[i]
		if(points[i]-tmpTime*c.toInt() < 0){
			continue
		}else{
			Radewoosh += points[i]-tmpTime*c.toInt()
		}
	}
	when {
		Limak > Radewoosh -> println("Limak")
		Limak < Radewoosh -> println("Radewoosh")
		else -> println("Tie")
	}

}


import kotlin.math.max

/* http://codeforces.com/problemset/problem/658/A */

fun main() {
    val (_, losingRate) = readLine()!!.split(" ").map { it.toInt() }
    val scores = readLine()!!.split(" ").map { it.toInt() }
    val times = readLine()!!.split(" ").map { it.toInt() }
    val timesPassed = times.sumPrefixes()
    val scoresReversed = scores.asReversed()
    val timesReversed = times.asReversed()
    val timesReversedPassed = timesReversed.sumPrefixes()
    val limakScore = scores.mapIndexed { index, score -> max(0, score - losingRate * timesPassed[index]) }.sum()
    val radewooshScore = scoresReversed.mapIndexed { index, score -> max(0, score - losingRate * timesReversedPassed[index]) }.sum()
    when {
        limakScore > radewooshScore -> println("Limak")
        radewooshScore > limakScore -> println("Radewoosh")
        else -> println("Tie")
    }
}

private fun List<Int>.sumPrefixes(): List<Int> {
    if (this.isEmpty()) {
        return emptyList()
    }
    val resultList = ArrayList<Int>(this.size)
    resultList.add(this[0])
    for (i in 1 until this.size) {
        resultList.add(resultList[i - 1] + this[i])
    }
    return resultList
}


fun main(args: Array<String>) {
    val reader = java.util.Scanner(System.`in`)
    val n = reader.nextInt()
    val c = reader.nextInt()
    val ps = ArrayList<Int>(n)
    val pssum = ArrayList<Int>(n)
    val pssumrev = ArrayList<Int>(n)

    val ts = ArrayList<Int>(n)
    for (i in 1..n) {
        ps.add(reader.nextInt())
        pssum.add(0)
        pssumrev.add(0)
    }

    for (i in 1..n)
        ts.add(reader.nextInt())

    var sum : Int=0
    var sumrev : Int = 0
    for (i in ts.indices) {
        sum += ts[i]
        sumrev += ts[n-i-1]
        pssum[i]=sum
        pssumrev[n-i-1]=sumrev
    }

    val a= ps.zip(pssum){a, b -> if (a<c*b) 0 else a-c*b}.sum()
    val b= ps.zip(pssumrev){a, b -> if (a<c*b) 0 else a-c*b}.sum()
    val r = if (a == b) "Tie" else if (a>b) "Limak" else "Radewoosh"
    println(r)
    //println("Limak=$a Radewoosh=$b")

}


@file:Suppress("NOTHING_TO_INLINE", "EXPERIMENTAL_FEATURE_WARNING", "OVERRIDE_BY_INLINE")

import java.io.PrintWriter
import java.util.StringTokenizer
import kotlin.math.*
import kotlin.random.Random
import kotlin.collections.sort as _sort
import kotlin.collections.sortDescending as _sortDescending
import kotlin.io.println as iprintln

/** @author Spheniscine */
fun main() { _writer.solve(); _writer.flush() }
fun PrintWriter.solve() {
    val percent = ModInt(100).inverse()

    val n = readInt()
    val pipes = List(n) { Pipe(readInt(), readInt(), percent * readInt()) }
    val tree = SegmentTree(n, null, nullIdentityCombiner(Seg::plus))

    tree.build { i ->
        Seg(
            ll = 1 - pipes[i].p,
            lr = ModInt(0),
            rl = ModInt(0),
            rr = pipes[i].p,
            ban = NONE
        )
    }

    val cols = ArrayList<Collision>(n-1 shl 1)

    for(i in 0 until n-1) {
        val a = pipes[i]
        val b = pipes[i+1]

        val d = b.x - a.x
        cols.add(Collision(i, RL, d, a.v + b.v))
        if(a.v > b.v) cols.add(Collision(i, RR, d, a.v - b.v))
        else if(a.v < b.v) cols.add(Collision(i, LL, d, b.v - a.v))
    }

    cols.sortWith(Collision.comparator)

    val vi = ModIntArray(cols.size) { ModInt(cols[it].v) }.inverseOfEach()
    var currProb = ModInt(1)
    var ans = ModInt(0)
    for(i in cols.indices) {
        val (a, t, d) = cols[i]
        tree[a] = tree[a]!!.copy(ban = t)
        val prob = tree.root!!.sum
        ans += (currProb - prob) * d * vi[i]
        currProb = prob
    }

    println(ans.int)
}

data class Pipe(val x: Int, val v: Int, val p: ModInt)
data class Collision(val a: Int, val type: CollisionType, val d: Int, val v: Int) {
    companion object {
        val comparator = Comparator<Collision> { a, b ->
            (a.d.toLong() * b.v).compareTo(b.d.toLong() * a.v)
        }
    }
}

typealias CollisionType = Byte
const val NONE: CollisionType = 0
const val LL: CollisionType = 1
const val RL: CollisionType = 2
const val RR: CollisionType = 3

data class Seg(val ll: ModInt, val lr: ModInt, val rl: ModInt, val rr: ModInt, val ban: CollisionType) {
    val sum get() = ll + lr + rl + rr

    operator fun plus(b: Seg): Seg {
        // LR never banned
        var cll = ll * b.rl
        var clr = ll * b.rr
        var crl = rl * b.rl
        var crr = rl * b.rr

        // any ban implies RL banned
        if(ban == NONE) {
            cll += lr * b.ll
            clr += lr * b.lr
            crl += rr * b.ll
            crr += rr * b.lr
        }

        if(ban != LL) {
            cll += ll * b.ll
            clr += ll * b.lr
            crl += rl * b.ll
            crr += rl * b.lr
        }

        if(ban != RR) {
            cll += lr * b.rl
            clr += lr * b.rr
            crl += rr * b.rl
            crr += rr * b.rr
        }

        return Seg(cll, clr, crl, crr, b.ban)
    }
}

class SegmentTree<T>(
    val size: Int,
    val identityValue: T,
    val combiner: (T, T) -> T) {

    private val tsize get() = if(size <= 1) size else Integer.highestOneBit(size - 1) shl 1

    /* degenericization helpers
    val identityValue: T = TODO()
    fun combiner(a: T, b: T): T = TODO()
    */

    @Suppress("UNCHECKED_CAST")
    private val array = Array<Any?>(tsize shl 1) { identityValue } as Array<T>

    val root get() = array[1]

    inline val lastIndex get() = size - 1
    inline val indices get() = 0 until size
    val asList: List<T> by lazy {
        object : AbstractList<T>() {
            override val size: Int get() = this@SegmentTree.size
            override fun get(index: Int): T = this@SegmentTree[index]
        }
    }

    fun build(generator: (Int) -> T) {
        for(i in 0 until size) {
            array[i + tsize] = generator(i)
        }
        for(i in tsize-1 downTo 1) {
            array[i] = combiner(array[i shl 1], array[i shl 1 or 1])
        }
    }

    /** instantiates values from an iterable, O(n) time */
    fun copyFrom(iterable: Iterable<T>) {
        run {
            iterable.forEachIndexed { i, t ->
                if(i > lastIndex) return@run
                array[i + tsize] = t
            }
        }
        for(i in tsize-1 downTo 1) {
            array[i] = combiner(array[i shl 1], array[i shl 1 or 1])
        }
    }

    /** Updates a value, O(log n) time */
    operator fun set(index: Int, value: T) {
        require(index in 0 until size)
        var i = index + tsize
        array[i] = value
        while(true) {
            i = i shr 1
            if(i <= 0) break
            array[i] = combiner(array[i shl 1], array[i shl 1 or 1])
        }
    }

    /** Gets a value by its index, O(1) time */
    operator fun get(index: Int): T {
        require(index in 0 until size)
        return array[index + tsize]
    }

    /** gets the result of applying the monoid operation to the values in the index range, O(log n) time */
    operator fun get(start: Int, endExclusive: Int): T {
        var l = maxOf(start, 0) + tsize
        var r = minOf(endExclusive, size) + tsize

        // two accumulators to support non-commutative monoids
        var lAcc = identityValue
        var rAcc = identityValue

        while(l < r) {
            if(l and 1 == 1) {
                lAcc = combiner(lAcc, array[l++])
            }
            if(r and 1 == 1) {
                rAcc = combiner(array[--r], rAcc)
            }

            l = l shr 1
            r = r shr 1
        }

        return combiner(lAcc, rAcc)
    }

    operator fun get(range: IntRange) = get(range.first, range.last + 1)
}

/** Converts a semigroup to a monoid by using null as the identity value. */
inline fun <T: Any> nullIdentityCombiner(crossinline combiner: (T, T) -> T): (T?, T?) -> T? = { a, b ->
    when {
        b == null -> a
        a == null -> b
        else -> combiner(a, b)
    }
}

fun ModIntArray.inverseOfEach(): ModIntArray {
    if(isEmpty()) return this
    var acc = ModInt(1)
    val res = ModIntArray(size) { i ->
        acc *= this[i]
        acc
    }
    acc = acc.inv_unmemoized()
    for(i in lastIndex downTo 1) {
        res[i] = acc * res[i-1]
        acc *= this[i]
    }
    res[0] = acc

    return res
}

const val MOD = 998244353
const val TOTIENT = MOD - 1 // assumes MOD is prime

infix fun Int.umod(mod: Int): Int = (this % mod).let { (it shr Int.SIZE_BITS - 1 and mod) + it }
infix fun Long.umod(mod: Long) = (this % mod).let { (it shr Long.SIZE_BITS - 1 and mod) + it }
infix fun Long.umod(mod: Int) = umod(mod.toLong()).toInt()

fun Int.mulMod(other: Int, mod: Int) = toLong() * other umod mod

fun Int.powMod(exponent: Int, mod: Int): Int {
    if(exponent < 0) error("Inverse not implemented")
    var res = 1L
    var e = exponent
    var b = umod(mod).toLong()

    while(e > 0) {
        if(e and 1 == 1) {
            res = res * b % mod
        }
        e = e shr 1
        b = b * b % mod
    }
    return res.toInt()
}

inline fun Int.toModInt() = ModInt(this umod MOD)
inline fun Long.toModInt() = ModInt(this umod MOD)

/** note: Only use constructor for int within modulo range, otherwise use toModInt **/
inline class ModInt(val int: Int) {
    companion object {
        /** can't seem to make these private or inlined without causing compiler issues */
        @JvmField val _invMemo = HashMap<ModInt, ModInt>()
        fun _invMemoized(m: ModInt) = _invMemo.getOrPut(m) { m.inv_unmemoized() }
    }

    // normalizes an integer that's within range [-MOD, MOD) without branching
    private inline fun normalize(int: Int) = ModInt((int shr Int.SIZE_BITS - 1 and MOD) + int)

    operator fun plus(other: ModInt) = normalize(int + other.int - MOD) // overflow-safe even if MOD >= 2^30
    inline operator fun plus(other: Int) = plus(other.toModInt())
    operator fun inc() = normalize(int + (1 - MOD))

    operator fun minus(other: ModInt) = normalize(int - other.int)
    inline operator fun minus(other: Int) = minus(other.toModInt())
    operator fun dec() = normalize(int - 1)
    operator fun unaryMinus() = normalize(-int)

    operator fun times(other: ModInt) = ModInt((int.toLong() * other.int % MOD).toInt())
    inline operator fun times(other: Int) = ModInt(int.mulMod(other, MOD))

    fun pow(exponent: Int): ModInt {
        val e = if(exponent < 0) {
            require(int != 0) { "Can't invert/divide by 0" }
            exponent umod TOTIENT
        } else exponent
        return ModInt(int.powMod(e, MOD))
    }

    fun pow(exponent: Long) = if(int == 0) when {
        exponent > 0 -> this
        exponent == 0L -> ModInt(1)
        else -> error("Can't invert/divide by 0")
    } else pow(exponent umod TOTIENT)

    inline fun inverse() = inv_memoized() /** NOTE: Change if necessary */

    fun inv_unmemoized(): ModInt {
        require(int != 0) { "Can't invert/divide by 0" }
        return pow(TOTIENT - 1)
    }
    inline fun inv_memoized() = _invMemoized(this)

    operator fun div(other: ModInt) = times(other.inverse())
    inline operator fun div(other: Int) = div(other.toModInt())

    override inline fun toString() = int.toString()
}

inline operator fun Int.plus(modInt: ModInt) = modInt + this
inline operator fun Int.minus(modInt: ModInt) = toModInt() - modInt
inline operator fun Int.times(modInt: ModInt) = modInt * this
inline operator fun Int.div(modInt: ModInt) = modInt.inverse() * this

inline class ModIntArray(val intArray: IntArray): Collection<ModInt> {
    inline operator fun get(i: Int) = ModInt(intArray[i])
    inline operator fun set(i: Int, v: ModInt) { intArray[i] = v.int }

    override inline val size: Int get() = intArray.size
    inline val lastIndex get() = intArray.lastIndex
    inline val indices get() = intArray.indices

    override inline fun contains(element: ModInt): Boolean = element.int in intArray

    override fun containsAll(elements: Collection<ModInt>): Boolean = elements.all(::contains)

    override inline fun isEmpty(): Boolean = intArray.isEmpty()

    override fun iterator(): Iterator<ModInt> = object: Iterator<ModInt> {
        var index = 0
        override fun hasNext(): Boolean = index < size
        override fun next(): ModInt = get(index++)
    }

    fun copyOf(newSize: Int) = ModIntArray(intArray.copyOf(newSize))
    fun copyOf() = copyOf(size)
}
fun ModIntArray.copyInto(destination: ModIntArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size) =
    ModIntArray(intArray.copyInto(destination.intArray, destinationOffset, startIndex, endIndex))
inline fun ModIntArray(size: Int) = ModIntArray(IntArray(size))
inline fun ModIntArray(size: Int, init: (Int) -> ModInt) = ModIntArray(IntArray(size) { init(it).int })

inline fun ModIntArray.first() = get(0)
inline fun ModIntArray.last() = get(lastIndex)
inline fun <R> ModIntArray.fold(init: R, op: (acc: R, ModInt) -> R) = intArray.fold(init) { acc, i -> op(acc, ModInt(i)) }
fun ModIntArray.sum() = fold(ModInt(0), ModInt::plus)
fun ModIntArray.product() = fold(ModInt(1), ModInt::times)

inline fun <T> Iterable<T>.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }
inline fun <T> Iterable<T>.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }
inline fun <T> Sequence<T>.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }
inline fun <T> Sequence<T>.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }
fun Iterable<ModInt>.sum() = sumByModInt { it }
fun Sequence<ModInt>.sum() = sumByModInt { it }
fun Iterable<ModInt>.product() = productByModInt { it }
fun Sequence<ModInt>.product() = productByModInt { it }
fun Collection<ModInt>.toModIntArray() = ModIntArray(size).also { var i = 0; for(e in this) { it[i++] = e } }

/** IO code start */
//@JvmField val INPUT = File("input.txt").inputStream()
//@JvmField val OUTPUT = File("output.txt").outputStream()
@JvmField val INPUT = System.`in`
@JvmField val OUTPUT = System.out

@JvmField val _reader = INPUT.bufferedReader()
fun readLine(): String? = _reader.readLine()
fun readLn() = _reader.readLine()!!
@JvmField var _tokenizer: StringTokenizer = StringTokenizer("")
fun read(): String {
    while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return "", " ")
    return _tokenizer.nextToken()
}
fun readInt() = read().toInt()
fun readDouble() = read().toDouble()
fun readLong() = read().toLong()
fun readStrings(n: Int) = List(n) { read() }
fun readLines(n: Int) = List(n) { readLn() }
fun readInts(n: Int) = List(n) { read().toInt() }
fun readIntArray(n: Int) = IntArray(n) { read().toInt() }
fun readDoubles(n: Int) = List(n) { read().toDouble() }
fun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }
fun readLongs(n: Int) = List(n) { read().toLong() }
fun readLongArray(n: Int) = LongArray(n) { read().toLong() }

@JvmField val _writer = PrintWriter(OUTPUT, false)

/** shuffles and sort overrides to avoid quicksort attacks */
private inline fun <T> _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {
    // Fisher-Yates shuffle algorithm
    for (i in size - 1 downTo 1) {
        val j = rnd.nextInt(i + 1)
        val temp = get(i)
        set(i, get(j))
        set(j, temp)
    }
}

//@JvmField var _random: Random? = null
val random = Random(0x594E215C123 * System.nanoTime())

fun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
fun IntArray.sort() { shuffle(); _sort() }
fun IntArray.sortDescending() { shuffle(); _sortDescending() }

fun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
fun LongArray.sort() { shuffle(); _sort() }
fun LongArray.sortDescending() { shuffle(); _sortDescending() }

fun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
fun DoubleArray.sort() { shuffle(); _sort() }
fun DoubleArray.sortDescending() { shuffle(); _sortDescending() }

fun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
inline fun CharArray.sort() { _sort() }
inline fun CharArray.sortDescending() { _sortDescending() }

inline fun <T: Comparable<T>> Array<out T>.sort() = _sort()
inline fun <T: Comparable<T>> Array<out T>.sortDescending() = _sortDescending()
inline fun <T: Comparable<T>> MutableList<out T>.sort() = _sort()
inline fun <T: Comparable<T>> MutableList<out T>.sortDescending() = _sortDescending()

fun `please stop removing these imports IntelliJ`() {
    iprintln(max(1, 2))
}


@file:Suppress("NOTHING_TO_INLINE", "EXPERIMENTAL_FEATURE_WARNING", "OVERRIDE_BY_INLINE")

import java.io.PrintWriter
import java.util.StringTokenizer
import kotlin.math.*
import kotlin.random.Random
import kotlin.collections.sort as _sort
import kotlin.collections.sortDescending as _sortDescending
import kotlin.io.println as iprintln

/** @author Spheniscine */
fun main() { _writer.solve(); _writer.flush() }
fun PrintWriter.solve() {
    val percent = ModInt(100).inverse()

    val n = readInt()
    val pipes = List(n) { Pipe(readInt(), readInt(), percent * readInt()) }
    val tree = SegmentTree(n, null, nullIdentityCombiner(Seg::plus))

    tree.build { i ->
        Seg(
            ll = 1 - pipes[i].p,
            lr = ModInt(0),
            rl = ModInt(0),
            rr = pipes[i].p,
            ban = NONE
        )
    }

    val cols = ArrayList<Collision>(n-1 shl 1)

    for(i in 0 until n-1) {
        val a = pipes[i]
        val b = pipes[i+1]

        val d = b.x - a.x
        cols.add(Collision(i, RL, d, a.v + b.v))
        if(a.v > b.v) cols.add(Collision(i, RR, d, a.v - b.v))
        else if(a.v < b.v) cols.add(Collision(i, LL, d, b.v - a.v))
    }

    cols.sortWith(Collision.comparator)

    val vi = ModIntArray(cols.size) { ModInt(cols[it].v) }.inverseOfEach()
    var currProb = ModInt(1)
    var ans = ModInt(0)
    for(i in cols.indices) {
        val (a, t, d) = cols[i]
        tree[a] = tree[a]!!.copy(ban = t)
        val prob = tree.root!!.sum
        ans += (currProb - prob) * d * vi[i]
        currProb = prob
    }

    println(ans.int)
}

data class Pipe(val x: Int, val v: Int, val p: ModInt)
data class Collision(val a: Int, val type: CollisionType, val d: Int, val v: Int) {
    companion object {
        val comparator = Comparator<Collision> { a, b ->
            (a.d.toLong() * b.v).compareTo(b.d.toLong() * a.v)
        }
    }
}

typealias CollisionType = Byte
const val NONE: CollisionType = 0
const val LL: CollisionType = 1
const val RL: CollisionType = 2
const val RR: CollisionType = 3

data class Seg(val ll: ModInt, val lr: ModInt, val rl: ModInt, val rr: ModInt, val ban: CollisionType) {
    val sum get() = ll + lr + rl + rr

    operator fun plus(b: Seg): Seg {
        // LR never banned
        var cll = ll * b.rl
        var clr = ll * b.rr
        var crl = rl * b.rl
        var crr = rl * b.rr

        // any ban implies RL banned
        if(ban == NONE) {
            cll += lr * b.ll
            clr += lr * b.lr
            crl += rr * b.ll
            crr += rr * b.lr
        }

        if(ban != LL) {
            cll += ll * b.ll
            clr += ll * b.lr
            crl += rl * b.ll
            crr += rl * b.lr
        }

        if(ban != RR) {
            cll += lr * b.rl
            clr += lr * b.rr
            crl += rr * b.rl
            crr += rr * b.rr
        }

        return Seg(cll, clr, crl, crr, b.ban)
    }
}

class SegmentTree<T>(
    val size: Int,
    val identityValue: T,
    val combiner: (T, T) -> T) {

    private val tsize get() = if(size <= 1) size else Integer.highestOneBit(size - 1) shl 1

    /* degenericization helpers
    val identityValue: T = TODO()
    fun combiner(a: T, b: T): T = TODO()
    */

    @Suppress("UNCHECKED_CAST")
    private val array = Array<Any?>(tsize shl 1) { identityValue } as Array<T>

    val root get() = array[1]

    inline val lastIndex get() = size - 1
    inline val indices get() = 0 until size
    val asList: List<T> by lazy {
        object : AbstractList<T>() {
            override val size: Int get() = this@SegmentTree.size
            override fun get(index: Int): T = this@SegmentTree[index]
        }
    }

    fun build(generator: (Int) -> T) {
        for(i in 0 until size) {
            array[i + tsize] = generator(i)
        }
        for(i in tsize-1 downTo 1) {
            array[i] = combiner(array[i shl 1], array[i shl 1 or 1])
        }
    }

    /** instantiates values from an iterable, O(n) time */
    fun copyFrom(iterable: Iterable<T>) {
        run {
            iterable.forEachIndexed { i, t ->
                if(i > lastIndex) return@run
                array[i + tsize] = t
            }
        }
        for(i in tsize-1 downTo 1) {
            array[i] = combiner(array[i shl 1], array[i shl 1 or 1])
        }
    }

    /** Updates a value, O(log n) time */
    operator fun set(index: Int, value: T) {
        require(index in 0 until size)
        var i = index + tsize
        array[i] = value
        while(true) {
            i = i shr 1
            if(i <= 0) break
            array[i] = combiner(array[i shl 1], array[i shl 1 or 1])
        }
    }

    /** Gets a value by its index, O(1) time */
    operator fun get(index: Int): T {
        require(index in 0 until size)
        return array[index + tsize]
    }

    /** gets the result of applying the monoid operation to the values in the index range, O(log n) time */
    operator fun get(start: Int, endExclusive: Int): T {
        var l = maxOf(start, 0) + tsize
        var r = minOf(endExclusive, size) + tsize

        // two accumulators to support non-commutative monoids
        var lAcc = identityValue
        var rAcc = identityValue

        while(l < r) {
            if(l and 1 == 1) {
                lAcc = combiner(lAcc, array[l++])
            }
            if(r and 1 == 1) {
                rAcc = combiner(array[--r], rAcc)
            }

            l = l shr 1
            r = r shr 1
        }

        return combiner(lAcc, rAcc)
    }

    operator fun get(range: IntRange) = get(range.first, range.last + 1)
}

/** Converts a semigroup to a monoid by using null as the identity value. */
inline fun <T: Any> nullIdentityCombiner(crossinline combiner: (T, T) -> T): (T?, T?) -> T? = { a, b ->
    when {
        a == null -> b
        b == null -> a
        else -> combiner(a, b)
    }
}

fun ModIntArray.inverseOfEach(): ModIntArray {
    if(isEmpty()) return this
    var acc = ModInt(1)
    val res = ModIntArray(size) { i ->
        acc *= this[i]
        acc
    }
    acc = res[lastIndex].inv_unmemoized()
    for(i in lastIndex downTo 1) {
        res[i] = acc * res[i-1]
        acc *= this[i]
    }
    res[0] = acc

    return res
}

const val MOD = 998244353
const val TOTIENT = MOD - 1 // assumes MOD is prime

infix fun Int.umod(mod: Int): Int = (this % mod).let { (it shr Int.SIZE_BITS - 1 and mod) + it }
infix fun Long.umod(mod: Long) = (this % mod).let { (it shr Long.SIZE_BITS - 1 and mod) + it }
infix fun Long.umod(mod: Int) = umod(mod.toLong()).toInt()

fun Int.mulMod(other: Int, mod: Int) = toLong() * other umod mod

fun Int.powMod(exponent: Int, mod: Int): Int {
    if(exponent < 0) error("Inverse not implemented")
    var res = 1L
    var e = exponent
    var b = umod(mod).toLong()

    while(e > 0) {
        if(e and 1 == 1) {
            res = res * b % mod
        }
        e = e shr 1
        b = b * b % mod
    }
    return res.toInt()
}

inline fun Int.toModInt() = ModInt(this umod MOD)
inline fun Long.toModInt() = ModInt(this umod MOD)

/** note: Only use constructor for int within modulo range, otherwise use toModInt **/
inline class ModInt(val int: Int) {
    companion object {
        /** can't seem to make these private or inlined without causing compiler issues */
        @JvmField val _invMemo = HashMap<ModInt, ModInt>()
        fun _invMemoized(m: ModInt) = _invMemo.getOrPut(m) { m.inv_unmemoized() }
    }

    // normalizes an integer that's within range [-MOD, MOD) without branching
    private inline fun normalize(int: Int) = ModInt((int shr Int.SIZE_BITS - 1 and MOD) + int)

    operator fun plus(other: ModInt) = normalize(int + other.int - MOD) // overflow-safe even if MOD >= 2^30
    inline operator fun plus(other: Int) = plus(other.toModInt())
    operator fun inc() = normalize(int + (1 - MOD))

    operator fun minus(other: ModInt) = normalize(int - other.int)
    inline operator fun minus(other: Int) = minus(other.toModInt())
    operator fun dec() = normalize(int - 1)
    operator fun unaryMinus() = normalize(-int)

    operator fun times(other: ModInt) = ModInt((int.toLong() * other.int % MOD).toInt())
    inline operator fun times(other: Int) = ModInt(int.mulMod(other, MOD))

    fun pow(exponent: Int): ModInt {
        val e = if(exponent < 0) {
            require(int != 0) { "Can't invert/divide by 0" }
            exponent umod TOTIENT
        } else exponent
        return ModInt(int.powMod(e, MOD))
    }

    fun pow(exponent: Long) = if(int == 0) when {
        exponent > 0 -> this
        exponent == 0L -> ModInt(1)
        else -> error("Can't invert/divide by 0")
    } else pow(exponent umod TOTIENT)

    inline fun inverse() = inv_memoized() /** NOTE: Change if necessary */

    fun inv_unmemoized(): ModInt {
        require(int != 0) { "Can't invert/divide by 0" }
        return pow(TOTIENT - 1)
    }
    inline fun inv_memoized() = _invMemoized(this)

    operator fun div(other: ModInt) = times(other.inverse())
    inline operator fun div(other: Int) = div(other.toModInt())

    override inline fun toString() = int.toString()
}

inline operator fun Int.plus(modInt: ModInt) = modInt + this
inline operator fun Int.minus(modInt: ModInt) = toModInt() - modInt
inline operator fun Int.times(modInt: ModInt) = modInt * this
inline operator fun Int.div(modInt: ModInt) = modInt.inverse() * this

inline class ModIntArray(val intArray: IntArray): Collection<ModInt> {
    inline operator fun get(i: Int) = ModInt(intArray[i])
    inline operator fun set(i: Int, v: ModInt) { intArray[i] = v.int }

    override inline val size: Int get() = intArray.size
    inline val lastIndex get() = intArray.lastIndex
    inline val indices get() = intArray.indices

    override inline fun contains(element: ModInt): Boolean = element.int in intArray

    override fun containsAll(elements: Collection<ModInt>): Boolean = elements.all(::contains)

    override inline fun isEmpty(): Boolean = intArray.isEmpty()

    override fun iterator(): Iterator<ModInt> = object: Iterator<ModInt> {
        var index = 0
        override fun hasNext(): Boolean = index < size
        override fun next(): ModInt = get(index++)
    }

    fun copyOf(newSize: Int) = ModIntArray(intArray.copyOf(newSize))
    fun copyOf() = copyOf(size)
}
fun ModIntArray.copyInto(destination: ModIntArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size) =
    ModIntArray(intArray.copyInto(destination.intArray, destinationOffset, startIndex, endIndex))
inline fun ModIntArray(size: Int) = ModIntArray(IntArray(size))
inline fun ModIntArray(size: Int, init: (Int) -> ModInt) = ModIntArray(IntArray(size) { init(it).int })

inline fun ModIntArray.first() = get(0)
inline fun ModIntArray.last() = get(lastIndex)
inline fun <R> ModIntArray.fold(init: R, op: (acc: R, ModInt) -> R) = intArray.fold(init) { acc, i -> op(acc, ModInt(i)) }
fun ModIntArray.sum() = fold(ModInt(0), ModInt::plus)
fun ModIntArray.product() = fold(ModInt(1), ModInt::times)

inline fun <T> Iterable<T>.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }
inline fun <T> Iterable<T>.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }
inline fun <T> Sequence<T>.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }
inline fun <T> Sequence<T>.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }
fun Iterable<ModInt>.sum() = sumByModInt { it }
fun Sequence<ModInt>.sum() = sumByModInt { it }
fun Iterable<ModInt>.product() = productByModInt { it }
fun Sequence<ModInt>.product() = productByModInt { it }
fun Collection<ModInt>.toModIntArray() = ModIntArray(size).also { var i = 0; for(e in this) { it[i++] = e } }

/** IO code start */
//@JvmField val INPUT = File("input.txt").inputStream()
//@JvmField val OUTPUT = File("output.txt").outputStream()
@JvmField val INPUT = System.`in`
@JvmField val OUTPUT = System.out

@JvmField val _reader = INPUT.bufferedReader()
fun readLine(): String? = _reader.readLine()
fun readLn() = _reader.readLine()!!
@JvmField var _tokenizer: StringTokenizer = StringTokenizer("")
fun read(): String {
    while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return "", " ")
    return _tokenizer.nextToken()
}
fun readInt() = read().toInt()
fun readDouble() = read().toDouble()
fun readLong() = read().toLong()
fun readStrings(n: Int) = List(n) { read() }
fun readLines(n: Int) = List(n) { readLn() }
fun readInts(n: Int) = List(n) { read().toInt() }
fun readIntArray(n: Int) = IntArray(n) { read().toInt() }
fun readDoubles(n: Int) = List(n) { read().toDouble() }
fun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }
fun readLongs(n: Int) = List(n) { read().toLong() }
fun readLongArray(n: Int) = LongArray(n) { read().toLong() }

@JvmField val _writer = PrintWriter(OUTPUT, false)

/** shuffles and sort overrides to avoid quicksort attacks */
private inline fun <T> _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {
    // Fisher-Yates shuffle algorithm
    for (i in size - 1 downTo 1) {
        val j = rnd.nextInt(i + 1)
        val temp = get(i)
        set(i, get(j))
        set(j, temp)
    }
}

//@JvmField var _random: Random? = null
val random = Random(0x594E215C123 * System.nanoTime())

fun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
fun IntArray.sort() { shuffle(); _sort() }
fun IntArray.sortDescending() { shuffle(); _sortDescending() }

fun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
fun LongArray.sort() { shuffle(); _sort() }
fun LongArray.sortDescending() { shuffle(); _sortDescending() }

fun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
fun DoubleArray.sort() { shuffle(); _sort() }
fun DoubleArray.sortDescending() { shuffle(); _sortDescending() }

fun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
inline fun CharArray.sort() { _sort() }
inline fun CharArray.sortDescending() { _sortDescending() }

inline fun <T: Comparable<T>> Array<out T>.sort() = _sort()
inline fun <T: Comparable<T>> Array<out T>.sortDescending() = _sortDescending()
inline fun <T: Comparable<T>> MutableList<out T>.sort() = _sort()
inline fun <T: Comparable<T>> MutableList<out T>.sortDescending() = _sortDescending()

fun `please stop removing these imports IntelliJ`() {
    iprintln(max(1, 2))
}


@file:Suppress("NOTHING_TO_INLINE", "EXPERIMENTAL_FEATURE_WARNING", "OVERRIDE_BY_INLINE")

import java.io.PrintWriter
import java.util.StringTokenizer
import kotlin.math.*
import kotlin.random.Random
import kotlin.collections.sort as _sort
import kotlin.collections.sortDescending as _sortDescending
import kotlin.io.println as iprintln

/** @author Spheniscine */
fun main() { _writer.solve(); _writer.flush() }
fun PrintWriter.solve() {
    val percent = ModInt(100).inverse()

    val n = readInt()
    val pipes = List(n) { Pipe(readInt(), readInt(), percent * readInt()) }
    val tree = SegmentTree(n, null, nullIdentityCombiner(Seg::plus))

    tree.build { i ->
        Seg(
            ll = 1 - pipes[i].p,
            lr = ModInt(0),
            rl = ModInt(0),
            rr = pipes[i].p,
            ban = NONE
        )
    }

    val cols = ArrayList<Collision>(n-1 shl 1)

    for(i in 0 until n-1) {
        val a = pipes[i]
        val b = pipes[i+1]

        val d = b.x - a.x
        cols.add(Collision(i, RL, d, a.v + b.v))
        if(a.v > b.v) cols.add(Collision(i, RR, d, a.v - b.v))
        else if(a.v < b.v) cols.add(Collision(i, LL, d, b.v - a.v))
    }

    cols.sortWith(Collision.comparator)

    val vi = ModIntArray(cols.size) { ModInt(cols[it].v) }.inverseOfEach()
    var currProb = ModInt(1)
    var ans = ModInt(0)
    for(i in cols.indices) {
        val (a, t, d) = cols[i]
        tree[a] = tree[a]!!.copy(ban = t)
        val prob = tree.root!!.sum
        ans += (currProb - prob) * d * vi[i]
        currProb = prob
    }

    println(ans.int)
}

data class Pipe(val x: Int, val v: Int, val p: ModInt)
data class Collision(val a: Int, val type: CollisionType, val d: Int, val v: Int) {
    companion object {
        val comparator = Comparator<Collision> { a, b ->
            (a.d.toLong() * b.v).compareTo(b.d.toLong() * a.v)
        }
    }
}

typealias CollisionType = Byte
const val NONE: CollisionType = 0
const val LL: CollisionType = 1
const val RL: CollisionType = 2
const val RR: CollisionType = 3

data class Seg(val ll: ModInt, val lr: ModInt, val rl: ModInt, val rr: ModInt, val ban: CollisionType) {
    val sum get() = ll + lr + rl + rr

    operator fun plus(b: Seg): Seg {
        // LR never banned
        var cll = ll * b.rl
        var clr = ll * b.rr
        var crl = rl * b.rl
        var crr = rl * b.rr

        // any ban implies RL banned
        if(ban == NONE) {
            cll += lr * b.ll
            clr += lr * b.lr
            crl += rr * b.ll
            crr += rr * b.lr
        }

        if(ban != LL) {
            cll += ll * b.ll
            clr += ll * b.lr
            crl += rl * b.ll
            crr += rl * b.lr
        }

        if(ban != RR) {
            cll += lr * b.rl
            clr += lr * b.rr
            crl += rr * b.rl
            crr += rr * b.rr
        }

        return Seg(cll, clr, crl, crr, b.ban)
    }
}

class SegmentTree<T>(
    val size: Int,
    val identityValue: T,
    val combiner: (T, T) -> T) {

    private val tsize get() = if(size <= 1) size else Integer.highestOneBit(size - 1) shl 1

    /* degenericization helpers
    val identityValue: T = TODO()
    fun combiner(a: T, b: T): T = TODO()
    */

    @Suppress("UNCHECKED_CAST")
    private val array = Array<Any?>(tsize shl 1) { identityValue } as Array<T>

    val root get() = array[1]

    inline val lastIndex get() = size - 1
    inline val indices get() = 0 until size
    val asList: List<T> by lazy {
        object : AbstractList<T>() {
            override val size: Int get() = this@SegmentTree.size
            override fun get(index: Int): T = this@SegmentTree[index]
        }
    }

    fun build(generator: (Int) -> T) {
        for(i in 0 until size) {
            array[i + tsize] = generator(i)
        }
        for(i in tsize-1 downTo 1) {
            array[i] = combiner(array[i shl 1], array[i shl 1 or 1])
        }
    }

    /** instantiates values from an iterable, O(n) time */
    fun copyFrom(iterable: Iterable<T>) {
        run {
            iterable.forEachIndexed { i, t ->
                if(i > lastIndex) return@run
                array[i + tsize] = t
            }
        }
        for(i in tsize-1 downTo 1) {
            array[i] = combiner(array[i shl 1], array[i shl 1 or 1])
        }
    }

    /** Updates a value, O(log n) time */
    operator fun set(index: Int, value: T) {
        require(index in 0 until size)
        var i = index + tsize
        array[i] = value
        while(true) {
            i = i shr 1
            if(i <= 0) break
            array[i] = combiner(array[i shl 1], array[i shl 1 or 1])
        }
    }

    /** Gets a value by its index, O(1) time */
    operator fun get(index: Int): T {
        require(index in 0 until size)
        return array[index + tsize]
    }

    /** gets the result of applying the monoid operation to the values in the index range, O(log n) time */
    operator fun get(start: Int, endExclusive: Int): T {
        var l = maxOf(start, 0) + tsize
        var r = minOf(endExclusive, size) + tsize

        // two accumulators to support non-commutative monoids
        var lAcc = identityValue
        var rAcc = identityValue

        while(l < r) {
            if(l and 1 == 1) {
                lAcc = combiner(lAcc, array[l++])
            }
            if(r and 1 == 1) {
                rAcc = combiner(array[--r], rAcc)
            }

            l = l shr 1
            r = r shr 1
        }

        return combiner(lAcc, rAcc)
    }

    operator fun get(range: IntRange) = get(range.first, range.last + 1)
}

/** Converts a semigroup to a monoid by using null as the identity value. */
inline fun <T: Any> nullIdentityCombiner(crossinline combiner: (T, T) -> T): (T?, T?) -> T? = { a, b ->
    when {
        a == null -> b
        b == null -> a
        else -> combiner(a, b)
    }
}

fun ModIntArray.inverseOfEach(): ModIntArray {
    if(isEmpty()) return this
    var acc = ModInt(1)
    val res = ModIntArray(size) { i ->
        acc *= this[i]
        acc
    }
    acc = acc.inv_unmemoized()
    for(i in lastIndex downTo 1) {
        res[i] = acc * res[i-1]
        acc *= this[i]
    }
    res[0] = acc

    return res
}

const val MOD = 998244353
const val TOTIENT = MOD - 1 // assumes MOD is prime

infix fun Int.umod(mod: Int): Int = (this % mod).let { (it shr Int.SIZE_BITS - 1 and mod) + it }
infix fun Long.umod(mod: Long) = (this % mod).let { (it shr Long.SIZE_BITS - 1 and mod) + it }
infix fun Long.umod(mod: Int) = umod(mod.toLong()).toInt()

fun Int.mulMod(other: Int, mod: Int) = toLong() * other umod mod

fun Int.powMod(exponent: Int, mod: Int): Int {
    if(exponent < 0) error("Inverse not implemented")
    var res = 1L
    var e = exponent
    var b = umod(mod).toLong()

    while(e > 0) {
        if(e and 1 == 1) {
            res = res * b % mod
        }
        e = e shr 1
        b = b * b % mod
    }
    return res.toInt()
}

inline fun Int.toModInt() = ModInt(this umod MOD)
inline fun Long.toModInt() = ModInt(this umod MOD)

/** note: Only use constructor for int within modulo range, otherwise use toModInt **/
inline class ModInt(val int: Int) {
    companion object {
        /** can't seem to make these private or inlined without causing compiler issues */
        @JvmField val _invMemo = HashMap<ModInt, ModInt>()
        fun _invMemoized(m: ModInt) = _invMemo.getOrPut(m) { m.inv_unmemoized() }
    }

    // normalizes an integer that's within range [-MOD, MOD) without branching
    private inline fun normalize(int: Int) = ModInt((int shr Int.SIZE_BITS - 1 and MOD) + int)

    operator fun plus(other: ModInt) = normalize(int + other.int - MOD) // overflow-safe even if MOD >= 2^30
    inline operator fun plus(other: Int) = plus(other.toModInt())
    operator fun inc() = normalize(int + (1 - MOD))

    operator fun minus(other: ModInt) = normalize(int - other.int)
    inline operator fun minus(other: Int) = minus(other.toModInt())
    operator fun dec() = normalize(int - 1)
    operator fun unaryMinus() = normalize(-int)

    operator fun times(other: ModInt) = ModInt((int.toLong() * other.int % MOD).toInt())
    inline operator fun times(other: Int) = ModInt(int.mulMod(other, MOD))

    fun pow(exponent: Int): ModInt {
        val e = if(exponent < 0) {
            require(int != 0) { "Can't invert/divide by 0" }
            exponent umod TOTIENT
        } else exponent
        return ModInt(int.powMod(e, MOD))
    }

    fun pow(exponent: Long) = if(int == 0) when {
        exponent > 0 -> this
        exponent == 0L -> ModInt(1)
        else -> error("Can't invert/divide by 0")
    } else pow(exponent umod TOTIENT)

    inline fun inverse() = inv_memoized() /** NOTE: Change if necessary */

    fun inv_unmemoized(): ModInt {
        require(int != 0) { "Can't invert/divide by 0" }
        return pow(TOTIENT - 1)
    }
    inline fun inv_memoized() = _invMemoized(this)

    operator fun div(other: ModInt) = times(other.inverse())
    inline operator fun div(other: Int) = div(other.toModInt())

    override inline fun toString() = int.toString()
}

inline operator fun Int.plus(modInt: ModInt) = modInt + this
inline operator fun Int.minus(modInt: ModInt) = toModInt() - modInt
inline operator fun Int.times(modInt: ModInt) = modInt * this
inline operator fun Int.div(modInt: ModInt) = modInt.inverse() * this

inline class ModIntArray(val intArray: IntArray): Collection<ModInt> {
    inline operator fun get(i: Int) = ModInt(intArray[i])
    inline operator fun set(i: Int, v: ModInt) { intArray[i] = v.int }

    override inline val size: Int get() = intArray.size
    inline val lastIndex get() = intArray.lastIndex
    inline val indices get() = intArray.indices

    override inline fun contains(element: ModInt): Boolean = element.int in intArray

    override fun containsAll(elements: Collection<ModInt>): Boolean = elements.all(::contains)

    override inline fun isEmpty(): Boolean = intArray.isEmpty()

    override fun iterator(): Iterator<ModInt> = object: Iterator<ModInt> {
        var index = 0
        override fun hasNext(): Boolean = index < size
        override fun next(): ModInt = get(index++)
    }

    fun copyOf(newSize: Int) = ModIntArray(intArray.copyOf(newSize))
    fun copyOf() = copyOf(size)
}
fun ModIntArray.copyInto(destination: ModIntArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size) =
    ModIntArray(intArray.copyInto(destination.intArray, destinationOffset, startIndex, endIndex))
inline fun ModIntArray(size: Int) = ModIntArray(IntArray(size))
inline fun ModIntArray(size: Int, init: (Int) -> ModInt) = ModIntArray(IntArray(size) { init(it).int })

inline fun ModIntArray.first() = get(0)
inline fun ModIntArray.last() = get(lastIndex)
inline fun <R> ModIntArray.fold(init: R, op: (acc: R, ModInt) -> R) = intArray.fold(init) { acc, i -> op(acc, ModInt(i)) }
fun ModIntArray.sum() = fold(ModInt(0), ModInt::plus)
fun ModIntArray.product() = fold(ModInt(1), ModInt::times)

inline fun <T> Iterable<T>.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }
inline fun <T> Iterable<T>.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }
inline fun <T> Sequence<T>.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }
inline fun <T> Sequence<T>.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }
fun Iterable<ModInt>.sum() = sumByModInt { it }
fun Sequence<ModInt>.sum() = sumByModInt { it }
fun Iterable<ModInt>.product() = productByModInt { it }
fun Sequence<ModInt>.product() = productByModInt { it }
fun Collection<ModInt>.toModIntArray() = ModIntArray(size).also { var i = 0; for(e in this) { it[i++] = e } }

/** IO code start */
//@JvmField val INPUT = File("input.txt").inputStream()
//@JvmField val OUTPUT = File("output.txt").outputStream()
@JvmField val INPUT = System.`in`
@JvmField val OUTPUT = System.out

@JvmField val _reader = INPUT.bufferedReader()
fun readLine(): String? = _reader.readLine()
fun readLn() = _reader.readLine()!!
@JvmField var _tokenizer: StringTokenizer = StringTokenizer("")
fun read(): String {
    while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return "", " ")
    return _tokenizer.nextToken()
}
fun readInt() = read().toInt()
fun readDouble() = read().toDouble()
fun readLong() = read().toLong()
fun readStrings(n: Int) = List(n) { read() }
fun readLines(n: Int) = List(n) { readLn() }
fun readInts(n: Int) = List(n) { read().toInt() }
fun readIntArray(n: Int) = IntArray(n) { read().toInt() }
fun readDoubles(n: Int) = List(n) { read().toDouble() }
fun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }
fun readLongs(n: Int) = List(n) { read().toLong() }
fun readLongArray(n: Int) = LongArray(n) { read().toLong() }

@JvmField val _writer = PrintWriter(OUTPUT, false)

/** shuffles and sort overrides to avoid quicksort attacks */
private inline fun <T> _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {
    // Fisher-Yates shuffle algorithm
    for (i in size - 1 downTo 1) {
        val j = rnd.nextInt(i + 1)
        val temp = get(i)
        set(i, get(j))
        set(j, temp)
    }
}

//@JvmField var _random: Random? = null
val random = Random(0x594E215C123 * System.nanoTime())

fun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
fun IntArray.sort() { shuffle(); _sort() }
fun IntArray.sortDescending() { shuffle(); _sortDescending() }

fun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
fun LongArray.sort() { shuffle(); _sort() }
fun LongArray.sortDescending() { shuffle(); _sortDescending() }

fun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
fun DoubleArray.sort() { shuffle(); _sort() }
fun DoubleArray.sortDescending() { shuffle(); _sortDescending() }

fun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
inline fun CharArray.sort() { _sort() }
inline fun CharArray.sortDescending() { _sortDescending() }

inline fun <T: Comparable<T>> Array<out T>.sort() = _sort()
inline fun <T: Comparable<T>> Array<out T>.sortDescending() = _sortDescending()
inline fun <T: Comparable<T>> MutableList<out T>.sort() = _sort()
inline fun <T: Comparable<T>> MutableList<out T>.sortDescending() = _sortDescending()

fun `please stop removing these imports IntelliJ`() {
    iprintln(max(1, 2))
}


@file:Suppress("NOTHING_TO_INLINE", "EXPERIMENTAL_FEATURE_WARNING", "OVERRIDE_BY_INLINE")

import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.PriorityQueue
import java.util.StringTokenizer
import java.util.TreeMap
import kotlin.math.*
import kotlin.random.*
import kotlin.collections.sort as _sort
import kotlin.collections.sortDescending as _sortDescending
import kotlin.io.println as iprintln

/** @author Spheniscine */
fun main() { _writer.solve(); _writer.flush() }
fun PrintWriter.solve() {
    val percent = ModInt(100).inverse()

    val n = readInt()
    val pipes = List(n) { Pipe(readInt(), readInt(), percent * readInt()) }
    val tree = SegmentTree(n, null, nullIdentityCombiner(Seg::plus))

    tree.build { i ->
        Seg(
            ll = pipes[i].p.not(),
            lr = ModInt(0),
            rl = ModInt(0),
            rr = pipes[i].p,
            ban = NONE
        )
    }

    val cols = ArrayList<Collision>(2*n)

    for(i in 0 until n-1) {
        val a = pipes[i]
        val b = pipes[i+1]

        val d = b.x - a.x
        cols.add(Collision(i, RL, d, a.v + b.v))
        if(a.v > b.v) cols.add(Collision(i, RR, d, a.v - b.v))
        else if(a.v < b.v) cols.add(Collision(i, LL, d, b.v - a.v))
    }

    cols.sortWith(Collision.comparator)

    var currProb = ModInt(1)
    var ans = ModInt(0)
    for((a, t, d, v) in cols) {
        tree[a] = tree[a]!!.copy(ban = t)
        val prob = tree.root!!.sum
        ans += (currProb - prob) * d / v
        currProb = prob
    }

    println(ans.int)
}

inline fun ModInt.not() = ModInt(1) - this

data class Pipe(val x: Int, val v: Int, val p: ModInt)
data class Collision(val a: Int, val type: CollisionType, val d: Int, val v: Int) {
    companion object {
        val comparator = Comparator<Collision> { a, b ->
            (a.d.toLong() * b.v).compareTo(b.d.toLong() * a.v)
        }
    }

    inline val b get() = a + 1
}

inline class CollisionType(val i: Int)
inline val NONE get() = CollisionType(0)
inline val LL get() = CollisionType(1)
inline val RL get() = CollisionType(2)
inline val RR get() = CollisionType(3)

data class Seg(val ll: ModInt, val lr: ModInt, val rl: ModInt, val rr: ModInt, val ban: CollisionType) {
    val sum get() = ll + lr + rl + rr

    operator fun plus(b: Seg): Seg {
        // LR never banned
        var cll = ll * b.rl
        var clr = ll * b.rr
        var crl = rl * b.rl
        var crr = rl * b.rr

        // any ban implies RL banned
        if(ban.i == NONE.i) {
            cll += lr * b.ll
            clr += lr * b.lr
            crl += rr * b.ll
            crr += rr * b.lr
        }

        if(ban.i != LL.i) {
            cll += ll * b.ll
            clr += ll * b.lr
            crl += rl * b.ll
            crr += rl * b.lr
        }

        if(ban.i != RR.i) {
            cll += lr * b.rl
            clr += lr * b.rr
            crl += rr * b.rl
            crr += rr * b.rr
        }

        return Seg(cll, clr, crl, crr, b.ban)
    }
}

class SegmentTree<T>(
    val size: Int,
    val identityValue: T,
    val combiner: (T, T) -> T) {

    private val tsize get() = if(size <= 1) size else Integer.highestOneBit(size - 1) shl 1

    /* degenericization helpers
    val identityValue: T = TODO()
    fun combiner(a: T, b: T): T = TODO()
    */

    @Suppress("UNCHECKED_CAST")
    private val array = Array<Any?>(2 * tsize) { identityValue } as Array<T>

    val root get() = array[1]

    inline val lastIndex get() = size - 1
    inline val indices get() = 0 until size
    val asList: List<T> by lazy {
        object : AbstractList<T>() {
            override val size: Int get() = this@SegmentTree.size
            override fun get(index: Int): T = this@SegmentTree[index]
        }
    }

    fun build(generator: (Int) -> T) {
        for(i in 0 until size) {
            array[i + tsize] = generator(i)
        }
        for(i in tsize-1 downTo 1) {
            array[i] = combiner(array[i shl 1], array[i shl 1 or 1])
        }
    }

    /** instantiates values from an iterable, O(n) time */
    fun copyFrom(iterable: Iterable<T>) {
        run {
            iterable.forEachIndexed { i, t ->
                if(i > lastIndex) return@run
                array[i + tsize] = t
            }
        }
        for(i in tsize-1 downTo 1) {
            array[i] = combiner(array[i shl 1], array[i shl 1 or 1])
        }
    }

    /** Updates a value, O(log n) time */
    operator fun set(index: Int, value: T) {
        require(index in 0 until size)
        var i = index + tsize
        array[i] = value
        while(true) {
            i = i shr 1
            if(i <= 0) break
            array[i] = combiner(array[i shl 1], array[i shl 1 or 1])
        }
    }

    /** Gets a value by its index, O(1) time */
    operator fun get(index: Int): T {
        require(index in 0 until size)
        return array[index + tsize]
    }

    /** gets the result of applying the monoid operation to the values in the index range, O(log n) time */
    operator fun get(start: Int, endExclusive: Int): T {
        var l = maxOf(start, 0) + tsize
        var r = minOf(endExclusive, size) + tsize

        // two accumulators to support non-commutative monoids
        var lAcc = identityValue
        var rAcc = identityValue

        while(l < r) {
            if(l and 1 == 1) {
                lAcc = combiner(lAcc, array[l++])
            }
            if(r and 1 == 1) {
                rAcc = combiner(array[--r], rAcc)
            }

            l = l shr 1
            r = r shr 1
        }

        return combiner(lAcc, rAcc)
    }

    operator fun get(range: IntRange) = get(range.first, range.last + 1)
}

/** Converts a semigroup to a monoid by using null as the identity value. */
inline fun <T: Any> nullIdentityCombiner(crossinline combiner: (T, T) -> T): (T?, T?) -> T? = { a, b ->
    when {
        a == null -> b
        b == null -> a
        else -> combiner(a, b)
    }
}

const val MOD = 998244353
const val TOTIENT = MOD - 1 // assumes MOD is prime

infix fun Int.umod(mod: Int): Int = (this % mod).let { (it shr Int.SIZE_BITS - 1 and mod) + it }
infix fun Long.umod(mod: Long) = (this % mod).let { (it shr Long.SIZE_BITS - 1 and mod) + it }
infix fun Long.umod(mod: Int) = umod(mod.toLong()).toInt()

fun Int.mulMod(other: Int, mod: Int) = toLong() * other umod mod

fun Int.powMod(exponent: Int, mod: Int): Int {
    if(exponent < 0) error("Inverse not implemented")
    var res = 1L
    var e = exponent
    var b = umod(mod).toLong()

    while(e > 0) {
        if(e and 1 == 1) {
            res = res * b % mod
        }
        e = e shr 1
        b = b * b % mod
    }
    return res.toInt()
}

inline fun Int.toModInt() = ModInt(this umod MOD)
inline fun Long.toModInt() = ModInt(this umod MOD)

/** note: Only use constructor for int within modulo range, otherwise use toModInt **/
inline class ModInt(val int: Int) {
    companion object {
        /** can't seem to make these private or inlined without causing compiler issues */
        @JvmField val _invMemo = HashMap<ModInt, ModInt>()
        fun _invMemoized(m: ModInt) = _invMemo.getOrPut(m) { m.inv_unmemoized() }
    }

    // normalizes an integer that's within range [-MOD, MOD) without branching
    private inline fun normalize(int: Int) = ModInt((int shr Int.SIZE_BITS - 1 and MOD) + int)

    operator fun plus(other: ModInt) = normalize(int + other.int - MOD) // overflow-safe even if MOD >= 2^30
    inline operator fun plus(other: Int) = plus(other.toModInt())
    operator fun inc() = normalize(int + (1 - MOD))

    operator fun minus(other: ModInt) = normalize(int - other.int)
    inline operator fun minus(other: Int) = minus(other.toModInt())
    operator fun dec() = normalize(int - 1)
    operator fun unaryMinus() = normalize(-int)

    operator fun times(other: ModInt) = ModInt((int.toLong() * other.int % MOD).toInt())
    inline operator fun times(other: Int) = ModInt(int.mulMod(other, MOD))

    fun pow(exponent: Int): ModInt {
        val e = if(exponent < 0) {
            require(int != 0) { "Can't invert/divide by 0" }
            exponent umod TOTIENT
        } else exponent
        return ModInt(int.powMod(e, MOD))
    }

    fun pow(exponent: Long) = if(int == 0) when {
        exponent > 0 -> this
        exponent == 0L -> ModInt(1)
        else -> error("Can't invert/divide by 0")
    } else pow(exponent umod TOTIENT)

    inline fun inverse() = inv_memoized() /** NOTE: Change if necessary */

    fun inv_unmemoized(): ModInt {
        require(int != 0) { "Can't invert/divide by 0" }
        return pow(TOTIENT - 1)
    }
    inline fun inv_memoized() = _invMemoized(this)

    operator fun div(other: ModInt) = times(other.inverse())
    inline operator fun div(other: Int) = div(other.toModInt())

    override inline fun toString() = int.toString()
}

inline operator fun Int.plus(modInt: ModInt) = modInt + this
inline operator fun Int.minus(modInt: ModInt) = toModInt() - modInt
inline operator fun Int.times(modInt: ModInt) = modInt * this
inline operator fun Int.div(modInt: ModInt) = modInt.inverse() * this

inline class ModIntArray(val intArray: IntArray): Collection<ModInt> {
    inline operator fun get(i: Int) = ModInt(intArray[i])
    inline operator fun set(i: Int, v: ModInt) { intArray[i] = v.int }

    override inline val size: Int get() = intArray.size
    inline val lastIndex get() = intArray.lastIndex
    inline val indices get() = intArray.indices

    override inline fun contains(element: ModInt): Boolean = element.int in intArray

    override fun containsAll(elements: Collection<ModInt>): Boolean = elements.all(::contains)

    override inline fun isEmpty(): Boolean = intArray.isEmpty()

    override fun iterator(): Iterator<ModInt> = object: Iterator<ModInt> {
        var index = 0
        override fun hasNext(): Boolean = index < size
        override fun next(): ModInt = get(index++)
    }

    fun copyOf(newSize: Int) = ModIntArray(intArray.copyOf(newSize))
    fun copyOf() = copyOf(size)
}
fun ModIntArray.copyInto(destination: ModIntArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size) =
    ModIntArray(intArray.copyInto(destination.intArray, destinationOffset, startIndex, endIndex))
inline fun ModIntArray(size: Int) = ModIntArray(IntArray(size))
inline fun ModIntArray(size: Int, init: (Int) -> ModInt) = ModIntArray(IntArray(size) { init(it).int })

inline fun ModIntArray.first() = get(0)
inline fun ModIntArray.last() = get(lastIndex)
inline fun <R> ModIntArray.fold(init: R, op: (acc: R, ModInt) -> R) = intArray.fold(init) { acc, i -> op(acc, ModInt(i)) }
fun ModIntArray.sum() = fold(ModInt(0), ModInt::plus)
fun ModIntArray.product() = fold(ModInt(1), ModInt::times)

inline fun <T> Iterable<T>.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }
inline fun <T> Iterable<T>.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }
inline fun <T> Sequence<T>.sumByModInt(func: (T) -> ModInt) = fold(ModInt(0)) { acc, t -> acc + func(t) }
inline fun <T> Sequence<T>.productByModInt(func: (T) -> ModInt) = fold(ModInt(1)) { acc, t -> acc * func(t) }
fun Iterable<ModInt>.sum() = sumByModInt { it }
fun Sequence<ModInt>.sum() = sumByModInt { it }
fun Iterable<ModInt>.product() = productByModInt { it }
fun Sequence<ModInt>.product() = productByModInt { it }
fun Collection<ModInt>.toModIntArray() = ModIntArray(size).also { var i = 0; for(e in this) { it[i++] = e } }

/** IO code start */
//@JvmField val INPUT = File("input.txt").inputStream()
//@JvmField val OUTPUT = File("output.txt").outputStream()
@JvmField val INPUT = System.`in`
@JvmField val OUTPUT = System.out

@JvmField val _reader = INPUT.bufferedReader()
fun readLine(): String? = _reader.readLine()
fun readLn() = _reader.readLine()!!
@JvmField var _tokenizer: StringTokenizer = StringTokenizer("")
fun read(): String {
    while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return "", " ")
    return _tokenizer.nextToken()
}
fun readInt() = read().toInt()
fun readDouble() = read().toDouble()
fun readLong() = read().toLong()
fun readStrings(n: Int) = List(n) { read() }
fun readLines(n: Int) = List(n) { readLn() }
fun readInts(n: Int) = List(n) { read().toInt() }
fun readIntArray(n: Int) = IntArray(n) { read().toInt() }
fun readDoubles(n: Int) = List(n) { read().toDouble() }
fun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }
fun readLongs(n: Int) = List(n) { read().toLong() }
fun readLongArray(n: Int) = LongArray(n) { read().toLong() }

@JvmField val _writer = PrintWriter(OUTPUT, false)

/** shuffles and sort overrides to avoid quicksort attacks */
private inline fun <T> _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {
    // Fisher-Yates shuffle algorithm
    for (i in size - 1 downTo 1) {
        val j = rnd.nextInt(i + 1)
        val temp = get(i)
        set(i, get(j))
        set(j, temp)
    }
}

@JvmField var _random: Random? = null
val random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }

fun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
fun IntArray.sort() { shuffle(); _sort() }
fun IntArray.sortDescending() { shuffle(); _sortDescending() }

fun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
fun LongArray.sort() { shuffle(); _sort() }
fun LongArray.sortDescending() { shuffle(); _sortDescending() }

fun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
fun DoubleArray.sort() { shuffle(); _sort() }
fun DoubleArray.sortDescending() { shuffle(); _sortDescending() }

fun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
inline fun CharArray.sort() { _sort() }
inline fun CharArray.sortDescending() { _sortDescending() }

inline fun <T: Comparable<T>> Array<out T>.sort() = _sort()
inline fun <T: Comparable<T>> Array<out T>.sortDescending() = _sortDescending()
inline fun <T: Comparable<T>> MutableList<out T>.sort() = _sort()
inline fun <T: Comparable<T>> MutableList<out T>.sortDescending() = _sortDescending()

fun `please stop removing these imports IntelliJ`() {
    iprintln(max(1, 2))
}


fun main() {
    val numVertices = readLine()!!.toLong()
    print(1 + 3 * (numVertices - 3) + (numVertices - 3) * (numVertices - 4))
}


fun main() {
    val numVertices = readLine()!!.toLong()
    print(4 * (numVertices - 3) + (numVertices - 4) * (numVertices - 4))
}


import java.io.*
import java.lang.Math.abs
import java.util.*

fun solve(cin: FastReader, out: PrintWriter) {
    val n = cin.int()
    val m = cin.int()
    var cnt: Long = 0
    for (i in 1..m)
        for (j in 1..m)
            if ((i * i + j * j.toLong()) % m == 0L)
                cnt += ((n - i + 1 + m - 1) / m).toLong() * ((n - j + 1 + m - 1) / m).toLong()

    out.print(cnt)
}

class FastReader(input: InputStream) {
    private val br = BufferedReader(InputStreamReader(input))
    private var st = StringTokenizer("")

    fun next(): String {
        while (!st.hasMoreTokens())
            st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun int(): Int {
        return next().toInt()
    }

    fun double(): Double {
        return next().toDouble()
    }

    fun long(): Long {
        return next().toLong()
    }

    /**
     * Warning! Use carefully!
     */
    fun nextLine(): String {
        return br.readLine()
    }
}

fun main(args: Array<String>) {
    val cin = FastReader(System.`in`)
    val out = PrintWriter(BufferedOutputStream(System.out))
    solve(cin, out)
    out.flush()
}


fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    var ans = 0L
    for (i in 0 until m) {
        for (j in 0 until m) {
            if ((i * i + j * j) % m == 0) {
                val x = when {
                    i == 0 -> n / m
                    n >= i -> ((n - i) / m) + 1
                    else -> 0
                }
                val y = when {
                    j == 0 -> n / m
                    n >= j -> ((n - j) / m) + 1
                    else -> 0
                }
                ans += x.toLong() * y
            }
        }
    }
    println(ans)
}


import java.io.*
import java.lang.Math.abs
import java.util.*

fun solve(cin: FastReader, out: PrintWriter) {
    val n = cin.int()
    val m = cin.int()
    var cnt = 0
    var part = 0
    for (i in 1..m)
        for (j in 1..m)
            if ((i * i.toLong() + j * j.toLong()) % m == 0.toLong())
                cnt++
    for (i in 1..(n % m))
        for (j in 1..(n % m))
            if ((i * i.toLong() + j * j.toLong()) % m == 0.toLong())
                part++
    var c = 0
    for (i in 1..m)
        for (j in 1..(n % m))
            if ((i * i.toLong() + j * j.toLong()) % m == 0.toLong())
                c++
    out.print((n / m).toLong() * (n / m).toLong() * cnt + part + (n / m).toLong() * 2 * c)
}

class FastReader(input: InputStream) {
    private val br = BufferedReader(InputStreamReader(input))
    private var st = StringTokenizer("")

    fun next(): String {
        while (!st.hasMoreTokens())
            st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun int(): Int {
        return next().toInt()
    }

    fun double(): Double {
        return next().toDouble()
    }

    fun long(): Long {
        return next().toLong()
    }

    /**
     * Warning! Use carefully!
     */
    fun nextLine(): String {
        return br.readLine()
    }
}

fun main(args: Array<String>) {
    val cin = FastReader(System.`in`)
    val out = PrintWriter(BufferedOutputStream(System.out))
    solve(cin, out)
    out.flush()
}


import java.util.*

fun pair(x: Int): Int {
    if (x >= 0) {
        return x xor 1
    } else {
        return x.inv() xor 2
    }
}

fun current(x: Int) = when {
    x >= 0 -> x
    else -> x.inv()
}

fun opposite(x: Int) = pair(x.inv())

fun oppositePair(x: Int) = current(x) xor 3

fun main(args: Array<String>) = with(Scanner(System.`in`)) {
    val opposite = arrayOf(arrayOf(0, 8), arrayOf(4, 20), arrayOf(12, 16))
    val other = arrayOf(arrayOf(4, 16, 20, 12), arrayOf(8, 16.inv(), 2, 13.inv()),
            arrayOf(0.inv(), 4.inv(), 8.inv(), 21.inv()))
    val a = IntArray(24) { nextInt() }
    loop@ for (op in opposite.indices) {
        for (i in opposite[op]) {
            for (j in 0..3) {
                if (a[i + j] != a[i]) {
                    continue@loop
                }
            }
        }
        val x = other[op]
        for (i in 0..3) {
            if (a[current(x[i])] != a[pair(x[i])]) {
                continue@loop
            }
            if (a[opposite(x[i])] != a[oppositePair(x[i])]) {
                continue@loop
            }
        }
        if ((-1..1 step 2).any { delta ->
            !(0..3).any { a[current(x[it])] != a[opposite(x[(it + delta) and 3])] }
        }) {
            println("YES")
            return
        }
    }
    println("NO")
}


import java.util.*

val a = Array(25) {_ -> 0}

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)

    for (i in 1 until 25) {
        a[i] = sc.nextInt()
    }
    if ((same(intArrayOf(13,14,15,16)) && same(intArrayOf(17,18,19,20)) && same(intArrayOf(1,3,6,8))
            && same(intArrayOf(5,7,10,12)) && same(intArrayOf(9,11,21,23)) && same(intArrayOf(2,4,22,24))) ||
            (same(intArrayOf(13,14,15,16)) && same(intArrayOf(17,18,19,20)) && same(intArrayOf(9,11,6,8))
                    && same(intArrayOf(5,7,2,4)) && same(intArrayOf(1,3,21,23)) && same(intArrayOf(10,12,22,24))) ||
            (same(intArrayOf(1,2,3,4)) && same(intArrayOf(9,10,11,12)) && same(intArrayOf(13,14,7,8))
                    && same(intArrayOf(5,6,19,20)) && same(intArrayOf(17,18,23,24)) && same(intArrayOf(21,22,15,16))) ||
            (same(intArrayOf(1,2,3,4)) && same(intArrayOf(9,10,11,12)) && same(intArrayOf(5,6,15,16))
                    && same(intArrayOf(17,18,7,8)) && same(intArrayOf(21,22,19,20)) && same(intArrayOf(13,14,23,24))) ||
            (same(intArrayOf(5,6,7,8)) && same(intArrayOf(21,22,23,24)) && same(intArrayOf(1,2,14,16))
                    && same(intArrayOf(13,15,9,10)) && same(intArrayOf(11,12,17,19)) && same(intArrayOf(3,4,18,20))) ||
            (same(intArrayOf(5,6,7,8)) && same(intArrayOf(21,22,23,24)) && same(intArrayOf(1,2,17,19))
                    && same(intArrayOf(9,10,18,20)) && same(intArrayOf(11,12,14,16)) && same(intArrayOf(13,15,3,4)))
            ){
        println("YES")
    } else {
        println("NO")
    }
}

fun same(pos: IntArray): Boolean {
    return a[pos[0]] == a[pos[1]] && a[pos[1]] == a[pos[2]] && a[pos[2]] == a[pos[3]]
}


import java.io.*
import java.util.*

class C internal constructor(inputStream: InputStream, val out: PrintWriter) {
    companion object {
        val ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null
    }

    private val br = BufferedReader(InputStreamReader(inputStream))
    private var st = StringTokenizer("")

    internal fun hasNext(): Boolean {
        while (!st.hasMoreTokens()) {
            val readLine = br.readLine() ?: return false
            st = StringTokenizer(readLine)
        }
        return true
    }

    private operator fun next() =
            if (hasNext()) st.nextToken()!!
            else throw RuntimeException("No tokens")

    internal fun nextLine() =
            if (hasNext()) st.nextToken("\n")
            else throw RuntimeException("No tokens")

    private fun nextInt() = next().toInt()
    private fun nextIntArray(n: Int) = IntArray(n, { nextInt() })
    private fun nextIntArray(m: Int, n: Int) = Array(m, { nextIntArray(n) })

    private fun nextLong() = next().toLong()
    private fun nextLongArray(n: Int) = LongArray(n, { nextLong() })
    private fun nextLongArray(m: Int, n: Int) = Array(m, { nextLongArray(n) })

    private fun nextDouble() = next().toDouble()
    private fun nextDoubleArray(n: Int) = DoubleArray(n, { nextDouble() })
    private fun nextDoubleArray(m: Int, n: Int) = Array(m, { nextDoubleArray(n) })

    fun log() {
        if (!ONLINE_JUDGE) {
            println()
        }
    }

    inline fun log(arr: IntArray?, name: String = "") {
        if (!ONLINE_JUDGE) {
            print("#$name: ")
            println(arr)
        }
    }

    inline fun log(arr: DoubleArray?, name: String = "") {
        if (!ONLINE_JUDGE) {
            print("#$name: ")
            println(arr)
        }
    }

    inline fun <T> log(arr: Array<T>?, name: String = "") {
        if (!ONLINE_JUDGE) {
            print("#$name: ")
            println(arr)
        }
    }

    inline fun <T> log(stack: Stack<T>?, name: String = "") {
        if (!ONLINE_JUDGE) {
            print("#$name: ")
            println(stack)
        }
    }

    inline fun <T> log(list: List<T>?, name: String = "") {
        if (!ONLINE_JUDGE) {
            print("#$name: ")
            println(list)
        }
    }

    inline fun log(message: Any?, name: String = "") {
        if (!ONLINE_JUDGE) {
            print("#$name: ")
            println(message)
        }
    }

    inline fun print(message: Any?) = out.print(message)

    inline fun print(arr: IntArray?, separator: String = " ") {
        var prefix = false
        arr?.forEach {
            if (prefix) {
                print(separator)
            }
            prefix = true
            print(it)
        }
    }

    inline fun print(arr: DoubleArray?, separator: String = " ") {
        var prefix = false
        arr?.forEach {
            if (prefix) {
                print(separator)
            }
            prefix = true
            print(it)
        }
    }

    inline fun <T> print(arr: Array<T>?, separator: String = " ") {
        var prefix = false
        arr?.forEach {
            if (prefix) {
                print(separator)
            }
            prefix = true
            print(it)
        }
    }

    inline fun <T> print(list: List<T>?, separator: String = " ") {
        var prefix = false
        list?.forEach {
            if (prefix) {
                print(separator)
            }
            prefix = true
            print(it)
        }
    }

    inline fun <T> print(stack: Stack<T>?, separator: String = " ") {
        var prefix = false
        if (stack != null) {
            while (stack.isNotEmpty()) {
                if (prefix) {
                    print(separator)
                }
                prefix = true
                print(stack.pop())
            }
        }
    }

    inline fun println() = out.println()

    inline fun println(message: Any?) = out.println(message)

    inline fun println(arr: IntArray?, separator: String = " ") {
        print(arr, separator)
        println()
    }

    inline fun println(arr: DoubleArray?, separator: String = " ") {
        print(arr, separator)
        println()
    }

    inline fun <T> println(list: List<T>?, separator: String = " ") {
        print(list, separator)
        println()
    }

    inline fun <T> println(arr: Array<T>?, separator: String = " ") {
        print(arr, separator)
        println()
    }

    inline fun <T> println(stack: Stack<T>?, separator: String = " ") {
        print(stack, separator)
        println()
    }

    val oppsite = arrayOf(2, 5, 0, 4, 3, 1)
    val next = arrayOf(arrayOf(3, 1, 4, 5),
                       arrayOf(2, 4, 0, 3),
                       arrayOf(3, 1, 4, 5),
                       arrayOf(0, 1, 2, 5),
                       arrayOf(0, 1, 2, 5),
                       arrayOf(2, 4, 0, 3))
    val match = arrayOf(arrayOf(arrayOf(1, 2, 3, 4, 3, 4),
                                arrayOf(1, 2, 3, 4, 3, 4),
                                arrayOf(1, 2, 3, 4, 3, 4),
                                arrayOf(1, 2, 3, 4, 3, 4)),
                        arrayOf(arrayOf(1, 2, 2, 4, 1, 3),
                                arrayOf(1, 3, 1, 2, 3, 4),
                                arrayOf(3, 4, 1, 3, 2, 4),
                                arrayOf(2, 4, 3, 4, 1, 2)),
                        arrayOf(arrayOf(3, 4, 1, 2, 1, 2),
                                arrayOf(3, 4, 1, 2, 1, 2),
                                arrayOf(3, 4, 1, 2, 1, 2),
                                arrayOf(3, 4, 1, 2, 1, 2)),
                        arrayOf(arrayOf(1, 3, 2, 4, 1, 3),//0
                                arrayOf(1, 3, 2, 4, 2, 4),//1
                                arrayOf(1, 3, 1, 3, 2, 4),//2
                                arrayOf(2, 4, 2, 4, 2, 4)),//5
                        arrayOf(arrayOf(2, 4, 1, 3, 1, 3),
                                arrayOf(2, 4, 1, 3, 1, 3),
                                arrayOf(2, 4, 1, 3, 2, 4),
                                arrayOf(1, 3, 1, 3, 1, 3)),
                        arrayOf(arrayOf(3, 4, 1, 3, 2, 4),
                                arrayOf(2, 4, 3, 4, 1, 2),
                                arrayOf(1, 2, 2, 4, 1, 3),
                                arrayOf(1, 3, 1, 2, 3, 4)))

    fun run() {

        val a = nextIntArray(6, 4)

        log(a.contentDeepToString())

        arrayOf(0, 1, 3).forEach {
            if (checkRotate(it, a)) {
                println("YES")
                return
            }
        }
        println("NO")
    }

    private fun checkRotate(upperIdx: Int, a: Array<IntArray>): Boolean {
        val upper = a[upperIdx]
        val bottom = a[oppsite[upperIdx]]

        if (!upper.isUnique() && !bottom.isUnique())
            return false

        var left = true
        var right = true
        repeat(4) {
            val face1 = a[next[upperIdx][it]]
            val face2 = a[next[upperIdx][(it + 1) % 4]]
            val face3 = a[next[upperIdx][(it + 3) % 4]]

            val m = match[upperIdx][it]
            if (face1[m[0] - 1] != face1[m[1] - 1])
                return false
            if (face2[m[2] - 1] != face2[m[3] - 1])
                left = false
            if (face3[m[4] - 1] != face3[m[5] - 1])
                right = false

            if (face1[m[0] - 1] != face2[m[3] - 1])
                left = false

            if (face1[m[0] - 1] != face3[m[4] - 1])
                right = false

        }
        return left || right
    }

}

private fun IntArray.isUnique() = !this.any { it != this[0] }

fun main(args: Array<String>) {
    if (C.ONLINE_JUDGE) {
        val a = C(System.`in`, PrintWriter(BufferedOutputStream(System.out)))
        a.run()
        a.out.flush()
        a.out.close()
    } else {
        val t = C(FileInputStream("C.txt"), PrintWriter(BufferedOutputStream(System.out)))
        while (t.hasNext()) {
            val name = t.nextLine()
            t.log("##### Test $name #####")
            val startTime = System.currentTimeMillis()
            t.run()
            val endTime = System.currentTimeMillis()
            t.log(endTime - startTime, "Total Time")
            t.log()
            t.out.flush()
        }
    }
}


import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*

val sc = FastScanner(System.`in`)
fun main(args: Array<String>) {
    val cube = Cube()

    val rotations = listOf(
        listOf(13, 14, 5, 6, 17, 18, 21, 22),
        listOf(1, 3, 5, 7, 9, 11, 24, 22),
        listOf(3, 4, 17, 19, 10, 9, 16, 14)
    )

    for (rotation in rotations) {
        cube.rotate(rotation)

        if (cube.isSolved) {
            println("YES")
            return
        }
        cube.rotate(rotation)
        cube.rotate(rotation)
        if (cube.isSolved) {
            println("YES")
            return
        }
        cube.rotate(rotation)
    }

    println("NO")

}

class Cube {
    private val colors = Array(24) { sc.nextInt() }

    private val sides = arrayOf(
        arrayOf(1, 2, 3, 4),
        arrayOf(5, 6, 7, 8),
        arrayOf(13, 14, 15, 16),
        arrayOf(17, 18, 19, 20),
        arrayOf(21, 22, 23, 24),
        arrayOf(9, 10, 11, 12)
    )

    fun rotate(rotation: List<Int>) {
        val x = colors[rotation[0] - 1]
        val y = colors[rotation[1] - 1]
        for (i in 0..2) {

            colors[rotation[2 * i] - 1] = colors[rotation[2 * i + 2] - 1]
            colors[rotation[2 * i + 1] - 1] = colors[rotation[2 * i + 3] - 1]
        }

        colors[rotation[6] - 1] = x
        colors[rotation[7] - 1] = y
    }

    val isSolved: Boolean
        get() {
            for (side in sides) {
                if (side.map { colors[it - 1] }.distinct().size != 1) return false
            }
            return true
        }

}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


@file:Suppress("NOTHING_TO_INLINE", "EXPERIMENTAL_FEATURE_WARNING", "OVERRIDE_BY_INLINE")

import java.io.PrintWriter
import java.util.PriorityQueue
import java.util.StringTokenizer
import kotlin.math.*
import kotlin.random.*
import kotlin.collections.sort as _sort
import kotlin.collections.sortDescending as _sortDescending
import kotlin.io.println as iprintln

/** @author Spheniscine */
fun main() { _writer.solve(); _writer.flush() }
fun PrintWriter.solve() {
    var ans = readLn().replace(Regex("""//+"""), "/")
    if(ans.length > 1) ans = ans.removeSuffix("/")
    println(ans)
}

/** IO code start */
//@JvmField val INPUT = File("input.txt").inputStream()
//@JvmField val OUTPUT = File("output.txt").outputStream()
@JvmField val INPUT = System.`in`
@JvmField val OUTPUT = System.out

@JvmField val _reader = INPUT.bufferedReader()
fun readLine(): String? = _reader.readLine()
fun readLn() = _reader.readLine()!!
@JvmField var _tokenizer: StringTokenizer = StringTokenizer("")
fun read(): String {
    while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return "", " ")
    return _tokenizer.nextToken()
}
fun readInt() = read().toInt()
fun readDouble() = read().toDouble()
fun readLong() = read().toLong()
fun readStrings(n: Int) = List(n) { read() }
fun readLines(n: Int) = List(n) { readLn() }
fun readInts(n: Int) = List(n) { read().toInt() }
fun readIntArray(n: Int) = IntArray(n) { read().toInt() }
fun readDoubles(n: Int) = List(n) { read().toDouble() }
fun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }
fun readLongs(n: Int) = List(n) { read().toLong() }
fun readLongArray(n: Int) = LongArray(n) { read().toLong() }

@JvmField val _writer = PrintWriter(OUTPUT, false)

/** shuffles and sort overrides to avoid quicksort attacks */
private inline fun <T> _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {
    // Fisher-Yates shuffle algorithm
    for (i in size - 1 downTo 1) {
        val j = rnd.nextInt(i + 1)
        val temp = get(i)
        set(i, get(j))
        set(j, temp)
    }
}

@JvmField var _random: Random? = null
val random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }

fun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
fun IntArray.sort() { shuffle(); _sort() }
fun IntArray.sortDescending() { shuffle(); _sortDescending() }

fun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
fun LongArray.sort() { shuffle(); _sort() }
fun LongArray.sortDescending() { shuffle(); _sortDescending() }

fun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
fun DoubleArray.sort() { shuffle(); _sort() }
fun DoubleArray.sortDescending() { shuffle(); _sortDescending() }

fun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
inline fun CharArray.sort() { _sort() }
inline fun CharArray.sortDescending() { _sortDescending() }

inline fun <T: Comparable<T>> Array<out T>.sort() = _sort()
inline fun <T: Comparable<T>> Array<out T>.sortDescending() = _sortDescending()
inline fun <T: Comparable<T>> MutableList<out T>.sort() = _sort()
inline fun <T: Comparable<T>> MutableList<out T>.sortDescending() = _sortDescending()

fun `please stop removing these imports IntelliJ`() {
    iprintln(max(1, 2))
}


import java.util.*

fun main(args: Array<String>) {
    val input = Scanner(System.`in`)
    val a = input.nextInt()
    val b = input.nextInt()
    when {
        Math.log(a.toDouble())/a > Math.log(b.toDouble())/b -> System.out.println(">")
        Math.log(a.toDouble())/a < Math.log(b.toDouble())/b -> System.out.println("<")
        else -> System.out.print("=")
    }
}


import java.io.BufferedReader
import java.io.IOException
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*
import kotlin.collections.ArrayList
import kotlin.collections.HashMap
import kotlin.collections.HashSet
import kotlin.math.max
import kotlin.math.min

val scanner = Scanner(System.`in`)

fun main(args: Array<String>)
        = Thread { run() }.start()

fun run() {
    val a = scanner.nextInt()
    val b = scanner.nextInt()
    if (a == b)
        println("=")
    else if (a <= 1 || b <= 1) {
        if (max(a, b) == a)
            println(">")
        else
            println("<")
    }
    else {
        val k = Math.pow(b.toDouble(), a.toDouble() / b)
        if (a.toDouble() == k)
            println("=")
        else if (a > k)
            println(">")
        else
            println("<")
    }
}
class Scanner(s: InputStream) {
    var st: StringTokenizer? = null
    var br: BufferedReader = BufferedReader(InputStreamReader(s))
    @Throws(IOException::class)
    operator fun next(): String {
        while (st == null || !st!!.hasMoreTokens())
            st = StringTokenizer(br.readLine())
        return st!!.nextToken()
    }
    @Throws(IOException::class)
    fun nextInt(): Int {
        return Integer.parseInt(next())
    }
    @Throws(IOException::class)
    fun nextLong(): Long {
        return java.lang.Long.parseLong(next())
    }
    @Throws(IOException::class)
    fun nextLine(): String {
        return br.readLine()
    }
    @Throws(IOException::class)
    fun nextDouble(): Double {
        return java.lang.Double.parseDouble(next())
    }
    @Throws(IOException::class)
    fun ready(): Boolean {
        return br.ready()
    }
}
class Pair(val a: Int, val b: Int)
//class Triple(val a: Int, val b: Int, val c: Int)


import kotlin.math.log10

fun main(args: Array<String>) {
    val (x, y) = readLine()!!.split(" ").map { it.toInt() }
    print(when {
        y / log10(y.toDouble()) > x / log10(x.toDouble()) + 1e-9 -> ">"
        y / log10(y.toDouble()) < x / log10(x.toDouble()) - 1e-9 -> "<"
        else -> "="
    })
}


import java.io.BufferedReader
import java.io.IOException
import java.io.InputStreamReader
import java.io.InputStream
import java.util.*
import kotlin.math.log

fun main(args: Array<String>) {
    class Scanner(s: InputStream) {
        private var st: StringTokenizer? = null
        private var br: BufferedReader = BufferedReader(InputStreamReader(s))

        @Throws(IOException::class)
        operator fun next(): String {
            while (st == null || !st!!.hasMoreTokens())
                st = StringTokenizer(br.readLine())
            return st!!.nextToken()
        }

        @Throws(IOException::class)
        fun nextInt(): Int {
            return Integer.parseInt(next())
        }

        @Throws(IOException::class)
        fun nextLong(): Long {
            return java.lang.Long.parseLong(next())
        }

        @Throws(IOException::class)
        fun nextLine(): String {
            return br.readLine()
        }

        @Throws(IOException::class)
        fun nextDouble(): Double {
            return java.lang.Double.parseDouble(next())
        }

        @Throws(IOException::class)
        fun ready(): Boolean {
            return br.ready()
        }
    }

    val scan = Scanner(System.`in`)

    val x = scan.nextInt().toDouble()
    val y = scan.nextInt().toDouble()

    if(y* log(x, 10.0) < x*log(y, 10.0)) {
        println("<")
    } else if(y* log(x, 10.0) > x*log(y, 10.0)) {
        println(">")
    } else {
        println("=")
    }

}


import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val people = sc.nextInt()
    val food = sc.nextInt()
    val typescnt = 101

    val types = IntArray(typescnt, {0})
    for (i in 1..food) {
        types[sc.nextInt()] += 1
    }

    val eating = IntArray(typescnt, {0})

    for (i in 1..people) {
        var maxk = -1
        var maxkj = -1
        for (j in 1 until typescnt) {
            if (types[j] == 0)
                continue
            val coef = types[j] / (eating[j] + 1)
            if (coef > maxk) {
                maxk = coef
                maxkj = j
            }
        }
        if (maxkj != -1) {
            eating[maxkj] += 1
        }
    }

    var mind = 1000000

    for (i in 1 until typescnt) {
        if (eating[i] != 0) {
            val v = types[i] / eating[i]
            if (v < mind)
                mind = v
        }
    }

    if (mind == 1000000) {
        println("0")
    } else {
        println(mind)
    }

    val a = 2

}


fun main() {
    fun readInts() = readLine()!!.split(" ").map(String::toInt)

    val (numParticipants, numFoods) = readInts()
    val types = readInts()
    val typeToAmount = mutableMapOf<Int, Int>().withDefault { 0 }
    for (type in types) typeToAmount[type] = typeToAmount.getValue(type) + 1
    for (amountPerPerson in 1..numFoods) {
        val numFeedable =
            typeToAmount.entries.fold(0) { acc, mutableEntry -> acc + mutableEntry.value / amountPerPerson }
        if (numFeedable < numParticipants) return print(amountPerPerson - 1)
    }
    print(numFoods)
}


import java.util.*;

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readDouble() = readLn().toDouble() // single int
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints
private fun readDoubles() = readStrings().map { it.toDouble() } // list of ints

fun main(args: Array<String>) {
    solve()
    /*
    val t = readInt()
    repeat(t) {
        solve()
    }
    */
}

fun solve() {
    val (k, n) = readInts()
    val l = IntArray(101)
    for(x in readInts()) {
        l[x]++
    }
    var lhs = 0
    var rhs = 10000
    while(lhs != rhs) {
        val mid = (lhs + rhs + 1) / 2
        var can = 0
        for(x in l) {
            can += x / mid
        }
        if(can >= k) lhs = mid
        else rhs = mid - 1
    }
    println(lhs)
}

/*
useful things:
to read in multiple ints in one line
val (n, m, k) = readInts()

Java: int[] dx = new int[]{-1,1,0,0}
Kotlin: val dx = arrayOf(-1, 1, 0, 0)
*/


import kotlin.math.*

fun main() {
    var (n, t, k, d) = readLine()!!.split(" ").map{ it.toInt() }
    var time_A = ceil(n.toDouble() / k) * t
    var time_B = 0
    var oven1 = false
    var oven2 = false
    while(true) {
        if(time_B % t == 0){
            oven1 = false
            if(n > 0) {
                n -= k
                oven1 = true
            }
        }
        if(time_B >= d && (time_B - d) % t == 0) {
            oven2 = false
            if(n > 0) {
                n -= k
                oven2 = true
            }
        }
        if(!oven1 && !oven2) break
        time_B++
    }
    if(time_A <= time_B) println("NO")
    else println("YES")
}


import java.util.*;

fun main(args: Array<String>){
    var input = Scanner(System.`in`);
    var  n=input.nextInt();
    var  t=input.nextInt();
    var  k=input.nextInt();
    var  d=input.nextInt();

    if (((d / t) + 1) * k >= n) print("NO");
    else print("YES");
}


import java.io.PrintWriter
import java.util.StringTokenizer
import kotlin.math.ceil
import kotlin.math.pow
import kotlin.math.sqrt

//private val INPUT = File("input.txt").inputStream()
//private val OUTPUT = File("output.txt").outputStream()
private val INPUT = System.`in`
private val OUTPUT = System.out

private val bufferedReader = INPUT.bufferedReader()
private val outputWriter = PrintWriter(OUTPUT, false)
private fun readLn() = bufferedReader.readLine()!!

private fun readList() = readLn().split(' ')
private var tokenizer = StringTokenizer("")
private fun read(): String {
    while (tokenizer.hasMoreTokens().not()) tokenizer = StringTokenizer(readLn(), " ")
    return tokenizer.nextToken()
}

private fun readInt() = read().toInt()
private fun readLong() = read().toLong()
private fun readDouble() = read().toDouble()

private fun readIntList() = readList().map { it.toInt() }
private fun readLongList() = readList().map { it.toLong() }
private fun readDoubleList() = readList().map { it.toDouble() }

private fun readIntArray(n: Int = 0) =
    if (n == 0) readList().run { IntArray(size) { get(it).toInt() } } else IntArray(n) { readInt() }

private fun readLongArray(n: Int = 0) =
    if (n == 0) readList().run { LongArray(size) { get(it).toLong() } } else LongArray(n) { readLong() }

private fun readDoubleArray(n: Int = 0) =
    if (n == 0) readList().run { DoubleArray(size) { get(it).toDouble() } } else DoubleArray(n) { readDouble() }

private fun Int.modPositive(other: Int): Int = if (this % other < 0) ((this % other) + other) else (this % other)

private class `CF799-D2-A` {
    fun solveTestCase(): String {
        var n = readInt()
        val t = readInt()
        val k = readInt()
        val d = readInt()

        var currt = 0
        while(currt <= d) {
            n -= k
            currt += t
        }

        return  when (n > 0) {
            true -> "YES"
            false -> "NO"
        }

    }
}

fun main(args: Array<String>) {

    outputWriter.println(
        `CF799-D2-A`()
            .solveTestCase()
    )

    outputWriter.flush()
}


import java.util.Scanner;
import java.util.Arrays;
import java.util.*;
import java.math.*;
import java.io.*;

fun main(args: Array<String>) {
    var s = Scanner(System.`in`)
    var cakes = s.nextInt()
    var oven1 = s.nextInt()
    var nocake = s.nextInt()
    var oven2 = s.nextInt()
    Carrotscake(cakes ,oven1 , nocake,oven2)

}

fun Carrotscake(cakes:Int,oven1:Int,nocake:Int,oven2:Int){
    var timeforoven1 = (cakes+nocake-1)/nocake

    var o1= 0
    var o2= oven2
    for(i in 0 until timeforoven1 ){
     if(o1 <= o2) o1 += oven1;
            else o2 += oven1;
    }

  if (maxOf(o1, o2) < timeforoven1 * oven1)
  println("YES")
  else
  println("NO")

}