CF346C Number Transformation II

Description

You are given a sequence of positive integers $ x_{1},x_{2},...,x_{n} $ and two non-negative integers $ a $ and $ b $ . Your task is to transform $ a $ into $ b $ . To do that, you can perform the following moves: - subtract 1 from the current $ a $ ; - subtract $ a $ mod $ x_{i} $ $ (1

Input Format

The first line contains a single integer $ n $ ( $ 1

Output Format

Print a single integer — the required minimum number of moves needed to transform number $ a $ into number $ b $ .