1.

/** * FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS10
* * Problem: 10038 - Jolly Jumpers
* * Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=12&page=show_problem&problem=979
* * Savkina Ekaterina
* * @version 1.0, 29/04/2010
* * Status : Accepted
* * Runtime: 0.564 */
package jolly;

import java.util.Scanner;
import java.util.TreeSet;

public class Jolly_jumper {
public static void main(String... args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
int limit = sc.nextInt();
TreeSet<Integer> hs = new TreeSet<Integer>();
for (int i = 1; i < limit; i++) {
hs.add(i);
}
int last = sc.nextInt();
for (int i = 1; i < limit; i++) {
int temp = sc.nextInt();
int diff;

if (temp > last)
diff = temp - last;
else
diff = last - temp;
hs.remove(diff);
last = temp;
}
if (hs.size() == 0)
System.out.println("Jolly");
else
System.out.println("Not jolly");
}
}
}


2.

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS10
* Problem: 10038 - Jolly Jumpers
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=12&page=show_problem&problem=979
*
* @author Evgeni Pavlidis
* @version 1.0, 06/02/2010
*
* Method : Ad hoc
* Status : Accepted
* Runtime: 0.480
*/

import java.io.*;
import java.util.*;

class Main {

public static void main(String...args)
{
Scanner sc = new Scanner(System.in);

int n, alt, neu;
Set<Integer> set = new HashSet<Integer>();
while(sc.hasNextInt())
{
n = sc.nextInt();

if(n == 0)
{
System.out.println("Not jolly");
continue;
}

set.clear();
for(int i = 1; i < n; i++)
set.add(i);

alt = sc.nextInt();
for(int i = 1; i < n; i++)
{
neu = sc.nextInt();
set.remove(Math.abs(alt-neu));
alt = neu;
}

if(set.isEmpty())
System.out.println("Jolly");
else
System.out.println("Not jolly");
}
}
}