QOJ.ac

QOJ

حد الوقت: 3 s حد الذاكرة: 256 MB مجموع النقاط: 100 قابلة للهجوم ✓

#4307. 数组

الإحصائيات

给定一个数组 $a_1, a_2, \dots, a_n$。令 $x_1 = a_1$,且对于每个从 $2$ 到 $n$ 的 $i$,有 $x_i = x_{i-1} \bmod a_i$。

假设我们可以以任意方式重新排列 $a_1, \dots, a_n$。我们能得到的 $x_n$ 的最大可能值是多少?

输入格式

第一行包含一个整数 $n$ —— 数组的大小 ($2 \le n \le 10^5$)。

第二行包含 $n$ 个整数 $a_1, \dots, a_n$ ($1 \le a_i \le 10^5$)。

输出格式

输出一个整数 —— $x_n$ 的最大可能值。

样例

样例输入 1

5
5 5 10 17 23

样例输出 1

3

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.