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
  1. 4
    18 55 16 17
Output
  1. YES
Input
  1. 6
    40 41 43 44 44 44
Output
  1. NO
Input
  1. 8
    5 972 3 4 1 4 970 971
Output
  1. YES
  2.  
  3. 纯数学思维题目。。。写这个题目的目的 主要是有个去重的函数
  1. #include<cstdio>
  2. #include<cstring>
  3. #include<cmath>
  4. #include<queue>
  5. #include<algorithm>
  6. using namespace std;
  7. int s[];
  8. int main()
  9. {
  10. int n;
  11. scanf("%d",&n);
  12. for(int i=;i<n;i++)
  13. {
  14. scanf("%d",&s[i]);
  15. }
  16.  
  17. sort(s,s+n);
  18.  
  19. int len=unique(s,s+n)-s;//去重
  20.  
  21. int flog=;
  22.  
  23. for(int i=;i<len;i++)
  24. {
  25. if(s[i+]==s[i]+&&s[i+]==s[i+]+)
  26. {
  27. flog=;
  28. break;
  29. }
  30. }
  31. if(flog==)
  32. printf("YES\n");
  33. else
  34. printf("NO\n");
  35. return ;
  36. }
  1.  

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. Oracle时间日期计算--计算某一日期为一年中的第几周

    Oracle时间日期计算--计算某一日期为一年中的第几周 select to_char(sysdate-10,'yyyymmdd')||':iw:'||to_char(sysdate-10,'iw') ...

  2. OpenCV -Python 性能衡量和提升技术 | 十二

    目标 在图像处理中,由于每秒要处理大量操作,因此必须使代码不仅提供正确的解决方案,而且还必须以最快的方式提供.因此,在本章中,你将学习 衡量代码的性能. 一些提高代码性能的技巧. 你将看到以下功能:c ...

  3. 3分钟了解GPT Bert与XLNet的差异

    译者 | Arno 来源 | Medium XLNet是一种新的预训练模型,在20项任务中表现优于BERT,且有大幅度的提升. 这是什么原因呢? 在不了解机器学习的情况下,不难估计我们捕获的上下文越多 ...

  4. 【WPF学习】第六十章 创建控件模板

    经过数十天的忙碌,今天终于有时间写博客. 前面一章通过介绍有关模板工作方式相关的内容,同时介绍了FrameWorkElement下所有控件的模板.接下来将介绍如何构建一个简单的自定义按钮,并在该过程中 ...

  5. Python python 数据类型的相互转换

    # number 之间的相互转换 # int <=> float var1 = 1; print(type(var1)) #<class 'int'> res1 = float ...

  6. Python查看3Dnii文件

    from nibabel.viewers import OrthoSlicer3D from nibabel import nifti1 import nibabel as nib from matp ...

  7. SpringBoot中常见的错误

    数据源配置问题 原因 spring boot默认会加载org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration类, ...

  8. Java序列化机制剖析

    本文转载自longdick的博文<Java序列化算法透析>,原文地址:http://longdick.iteye.com Java序列化算法透析 Serialization(序列化)是一种 ...

  9. 怎么处理使用UINavigation(导航控制器时) UIScrollView及其子类UITableView、UICollectionView可能出现的向下偏移64Px或者顶部对齐等问题

    前言           近期在做项目时遇到了好几起由于自动偏移或则没有自动偏移而导致的界面布局问题,尤其是在昨晚新版本赶上IOS9系统升级的时候,刚升级完了后就发现项目里面很多使用UINavgati ...

  10. 三层架构之UI层

    之前已经发表了BLL,DAL,MODEL,三个层的源码 继续UI层: 先简单实现用户的登录及注册 高级操作可按照上一篇文章进行源码完善 如图所示↑ UI层目录文件 Reg.aspx 进行注册操作  & ...