Matrix Walk

题意翻译

## 【题目大意】 你有一个大小未知(假设为 $x\times y$)的矩阵,这个矩阵中的格子的编号的排列有规律,比如说 $(i,j)$ 号格子的编号为 $y\times (i - 1) + j$。 但是现在这个矩阵的大小是未知的,我们的任务是算出来这个矩阵的**任意一种可能的大小**。 接下来,你有一个长度为 $n$ 序列,表示你在矩阵中行动时走到的格子的编号。(你在矩阵中**只能上下左右行动,不能走出矩阵**) 如果说有符合这种序列的矩阵,那么输出 ```YES```,并输出矩阵的**任意一种可能的大小** ;否则输出 ```NO```。 ## 【输入格式】 第一行一个整数 $n$。 第二行 $n$ 个整数,表示这个序列。 ## 【输出格式】 我们需要的矩阵的大小。 ## 【数据范围】 $1 \le n\le 2 \times 10^5$,序列中任意的数字都小于等于 $10^9$,矩阵大小小于 $10 ^ 9\times 10^9$。

题目描述

There is a matrix $ A $ of size $ x×y $ filled with integers. For every ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF954C/4052ad629d73d292f3d91ab28d288872054d305e.png), ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF954C/4f9a677c517f4ca1a07ede7e6a04818468f95dc9.png) $ A_{i,j}=y(i-1)+j $ . Obviously, every integer from $ [1..xy] $ occurs exactly once in this matrix. You have traversed some path in this matrix. Your path can be described as a sequence of visited cells $ a_{1} $ , $ a_{2} $ , ..., $ a_{n} $ denoting that you started in the cell containing the number $ a_{1} $ , then moved to the cell with the number $ a_{2} $ , and so on. From the cell located in $ i $ -th line and $ j $ -th column (we denote this cell as $ (i,j) $ ) you can move into one of the following cells: 1. $ (i+1,j) $ — only if $ i<x $ ; 2. $ (i,j+1) $ — only if $ j<y $ ; 3. $ (i-1,j) $ — only if $ i>1 $ ; 4. $ (i,j-1) $ — only if $ j>1 $ . Notice that making a move requires you to go to an adjacent cell. It is not allowed to stay in the same cell. You don't know $ x $ and $ y $ exactly, but you have to find any possible values for these numbers such that you could start in the cell containing the integer $ a_{1} $ , then move to the cell containing $ a_{2} $ (in one step), then move to the cell containing $ a_{3} $ (also in one step) and so on. Can you choose $ x $ and $ y $ so that they don't contradict with your sequence of moves?

输入输出格式

输入格式


The first line contains one integer number $ n $ ( $ 1<=n<=200000 $ ) — the number of cells you visited on your path (if some cell is visited twice, then it's listed twice). The second line contains $ n $ integers $ a_{1} $ , $ a_{2} $ , ..., $ a_{n} $ ( $ 1<=a_{i}<=10^{9} $ ) — the integers in the cells on your path.

输出格式


If all possible values of $ x $ and $ y $ such that $ 1<=x,y<=10^{9} $ contradict with the information about your path, print NO. Otherwise, print YES in the first line, and in the second line print the values $ x $ and $ y $ such that your path was possible with such number of lines and columns in the matrix. Remember that they must be positive integers not exceeding $ 10^{9} $ .

输入输出样例

输入样例 #1

8
1 2 3 6 9 8 5 2

输出样例 #1

YES
3 3

输入样例 #2

6
1 2 1 2 5 3

输出样例 #2

NO

输入样例 #3

2
1 10

输出样例 #3

YES
4 9

说明

The matrix and the path on it in the first test looks like this: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF954C/da3fd791b135ae73cd5caaa5c7c71915c4114ae0.png)Also there exist multiple correct answers for both the first and the third examples.