Algorithm


problem link- https://www.spoj.com/problems/OLOLO/

OLOLO - Onotole needs your help

 

Onotole has a lot of pyani. Each pyani has a number, writing on it. Pyanis with equal numbers are indistinguishable. Onotole knows everything, so, he knows that each pyani appeared twice, and only one pyani is unique. He wants to get вздръжни эффект, and he needs the unique pyani. Given the list of pyanis denote which one of them appeared once (it is guaranteed that other pyanis appeared twice).

Input

First line of input contains number of pyanis N <= 500 000. Next N lines contain a single positive integer 1 <= Pi <= 10^9.

Output

Output one positive integer on pyani, which appeared once.

Example

Input:
3
1
8
1

Output: 8

Onotole has found not optimal AC algorithms, so all solutions will be rejudged. He is watching you.

 



 

Code Examples

#1 Code Example with C++ Programming

Code - C++ Programming

#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <map>

using namespace std;

int main(){
int n=0;
cin>>n;
long long int ans=0;
long long int temp;
while(n--){
	scanf("%lld",&temp);
	ans=ans^temp;	
}
printf("%lld\n",ans);
return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
3
1
8
1

Output

x
+
cmd
8

#2 Code Example with Java Programming

Code - Java Programming

#include
int main()
{
    int n,i;
    scanf("%d",&n);
    long long int arr[n];
    for(i=0;i<n;i++)
        scanf("%lld",&arr[i]);
    long long int a,ans;
    a=arr[0];
    for(i=1;i<n;i++)
    {
        ans=a^arr[i];
        a=ans;
    }
    printf("%lld\n",ans);
    return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
3
1
8
1

Output

x
+
cmd
8
Advertisements

Demonstration


SPOJ Soluution-Onotole needs your help-Solution in C, C++, Java, Python

Previous
SPOJ Solution - Test Life, the Universe, and Everything - Solution in C, C++, Java, Python