N = gets.to_i
A = gets.chomp.split.map(&:to_i)

ans = 0
h = {}
0.upto(N-2) do |i|
  (i+1).upto(N-1) do |j|
    if h.key?([A[i],A[j]])
      ans += h[[A[i], A[j]]]
      ans = ans.modulo(10**9+7)
      next
    elif h.key?([A[j],A[i]])
      ans += h[[A[j], A[i]]]
      ans = ans.modulo(10**9+7)
      next
    end
    ai = 
      if h.key?(A[i]) 
        h[A[i]]
      else
        h[A[i]] = A[i].modulo(10**9+7)
        h[A[i]]
      end
    aj =
      if h.key?(A[j]) 
        h[A[j]]
      else
        h[A[j]] = A[j].modulo(10**9+7)
        h[A[j]]
      end
    h[[A[i], A[j]]] = ai * aj
    h[[A[j], A[i]]] = ai * aj

    ans += h[[A[i], A[j]]]
    ans = ans.modulo(10**9+7)
  end
end

puts ans