Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- long long a[100005],n,i,res,x,y,f=0;
- cin>>n;
- for(i=0; i<n; i++)
- cin>>a[i];
- sort(a,a+n);
- x=a[0];
- for(i=1; i<n; i++)
- {
- if(x!=a[i])
- {
- y=a[i];
- f=1;
- break;
- }
- }
- if(f==1)
- {
- f=0;
- res=y-x;
- x=x+res;
- for(i=0; i<n; i++)
- {
- if(res>=a[i])
- a[i]=res+a[i];
- else if(a[i]>res&&x!=a[i])
- a[i]=a[i]-res;
- }
- for(i=0; i<n-1; i++)
- {
- if(a[i]!=a[i+1])
- f=1;
- }
- if(f==0&&a[0]==a[n-1])
- cout<<"YES"<<endl;
- else
- cout<<"NO"<<endl;
- }
- else
- cout<<"YES"<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement