uses crt;
var i,n,kt,j:longint; s:array[1..1000000]of longint;
begin
clrscr;
write('Nhap N (N<=20): ');readln(n);
for i:=1 to n do
begin
write('S[',i,']= ');readln(s[i]);
end;
for i:=1 to n do
begin
kt:=0;
for j:=1 to i-1 do
if s[i]=s[j] then inc(kt);
if kt=0 then
begin
for j:=i to n do
if s[i]=s[j] then inc(kt);
if kt>1 then write(s[i],' ');
end;
end;
readln
end.