N = gets.chomp.to_i A = gets.chomp.split.map(&:to_i) ans = 1 (0...N).each do |i| ((i + 1)...N).each do |j| ans = (ans * (A[i] - A[j])) % 998244353 end end puts ans