Limak is a little polar bear. He has n balls, the i-th ball has size ti.

Limak wants to give one ball to each of his three friends. Giving gifts isn't easy — there are two rules Limak must obey to make friends happy:

  • No two friends can get balls of the same size.
  • No two friends can get balls of sizes that differ by more than 2.

For example, Limak can choose balls with sizes 4, 5 and 3, or balls with sizes 90, 91 and 92. But he can't choose balls with sizes 5, 5 and 6 (two friends would get balls of the same size), and he can't choose balls with sizes 30, 31 and 33 (because sizes 30 and 33 differ by more than 2).

Your task is to check whether Limak can choose three balls that satisfy conditions above.

Input

The first line of the input contains one integer n (3 ≤ n ≤ 50) — the number of balls Limak has.

The second line contains n integers t1, t2, ..., tn (1 ≤ ti ≤ 1000) where ti denotes the size of the i-th ball.

Output

Print "YES" (without quotes) if Limak can choose three balls of distinct sizes, such that any two of them differ by no more than 2. Otherwise, print "NO" (without quotes).

Examples

Input
4
18 55 16 17
Output
YES
Input
6
40 41 43 44 44 44
Output
NO
Input
8
5 972 3 4 1 4 970 971
Output
YES

纯数学思维题目。。。写这个题目的目的 主要是有个去重的函数
#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include<algorithm>
using namespace std;
int s[];
int main()
{
int n;
scanf("%d",&n);
for(int i=;i<n;i++)
{
scanf("%d",&s[i]);
} sort(s,s+n); int len=unique(s,s+n)-s;//去重 int flog=; for(int i=;i<len;i++)
{
if(s[i+]==s[i]+&&s[i+]==s[i+]+)
{
flog=;
break;
}
}
if(flog==)
printf("YES\n");
else
printf("NO\n");
return ;
}

H - Bear and Three Balls的更多相关文章

  1. codeforces 653A Bear and Three Balls

    A. Bear and Three Balls time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  2. Bear and Three Balls

    链接:http://codeforces.com/problemset/problem/653/A                                                   ...

  3. 【codeforces】Bear and Three Balls(排序,去重)

    Bear and Three Balls Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I6 ...

  4. IndiaHacks 2016 - Online Edition (Div. 1 + Div. 2) A. Bear and Three Balls 水题

    A. Bear and Three Balls 题目连接: http://www.codeforces.com/contest/653/problem/A Description Limak is a ...

  5. codeforces 653A A. Bear and Three Balls(水题)

    题目链接: A. Bear and Three Balls time limit per test 2 seconds memory limit per test 256 megabytes inpu ...

  6. IndiaHacks 2016 - Online Edition (Div. 1 + Div. 2)——A - Bear and Three Balls(unique函数的使用)

    A. Bear and Three Balls time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  7. CodeForces 653 A. Bear and Three Balls——(IndiaHacks 2016 - Online Edition (Div. 1 + Div. 2))

    传送门 A. Bear and Three Balls time limit per test 2 seconds memory limit per test 256 megabytes input ...

  8. Codeforces 653A Bear and Three Balls【水题】

    题目链接: http://codeforces.com/problemset/problem/653/A 题意: 给定序列,找是否存在连续的三个数. 分析: 排序~去重~直接判断~~ 代码: #inc ...

  9. Tkinter 项目-屏保

    参考教程,以及网上资料,针对小白更好理解 关于tkinter的屏保涉及的知识点和思想 项目分析: 屏保启动方式:手动,自动 敲击键盘或者移动鼠标后,或者其他引发事件,则停止 如果屏保是一幅画的话,则没 ...

随机推荐

  1. django之forms组件,cookie&session

    forms组件 先自己实现注册功能,并且对用户输入的信息加限制条件如果用户输入的信息不符合条件,前端展示报错信息 from django.shortcuts import render,HttpRes ...

  2. SqlBulkCopy批量插入数据 显示 来自数据源的 String 类型的给定值不能转换为指定目标列的类型 smalldatetime。错误

    因为需要大量插入数据,linq ef无法达到速度的要求,因此把模型转换成SQL ,使用SqlBulkCopy快速插入.但是去提示 来自数据源的 String 类型的给定值不能转换为指定目标列的类型 s ...

  3. Falling Squares

    2020-01-08 10:16:37 一.Falling squares 问题描述: 问题求解: 本题其实也是一条经典的区间问题,对于区间问题,往往可以使用map来进行区间的维护操作. class ...

  4. npm git 常用命令行 记录

    1. 推出node命令行: 两次ctrl+C或者一次ctrl+D    退出终端:exit; 2.npm 常用 npm install <name>  安装包 npm install &l ...

  5. 深度学习框架Keras与Pytorch对比

    对于许多科学家.工程师和开发人员来说,TensorFlow是他们的第一个深度学习框架.TensorFlow 1.0于2017年2月发布,可以说,它对用户不太友好. 在过去的几年里,两个主要的深度学习库 ...

  6. 谷歌2019 学术指标发榜:CVPR首次进入Top 10,何恺明论文引用最高!

    [导读]今天,谷歌发布了2019最新版学术指标,对收录的会议和期刊的影响力进行排名.AI类的多个顶会进入榜单Top 100,CVPR更是进入前10,而何恺明的"深度残差网络"单篇引 ...

  7. vue2.0开发环境下解决跨域问题

    1.找到vue 项目下的配置文件 /config/index.js 2.找到 proxyTable 配置项 proxyTable: { '/api': { target: 'http://www.xx ...

  8. python入门灵魂5问--python学习路线,python教程,python学哪些,python怎么学,python学到什么程度

    一.python入门简介 对于刚接触python编程或者想学习python自动化的人来说,基本都会有以下python入门灵魂5问--python学习路线,python教程,python学哪些,pyth ...

  9. 一夜搞懂 | JVM 字节码执行引擎

    前言 本文已经收录到我的 Github 个人博客,欢迎大佬们光临寒舍: 我的 GIthub 博客 学习导图 一.为什么要学习字节码执行引擎? 代码编译的结果从本地机器码转变为字节码,是存储格式发展的一 ...

  10. 全网独家:成长经历分享 & 我为什么要写书?

    在当今高速发展的移动互联网+云优先的时代,到处充斥着不可预知的变化,有的来自于客户需求的变化,有的来自于市场环境的变化,面对着这些变化,给企业在市场.渠道.产品.服务各方面都带来了一系列新的挑战,每个 ...