n = int(input()) *a, = map(int,input().split()) r = [0]*101 for ai in a: r[ai] += 1 MOD = 10**9+7 x,y,z,w = 1,0,0,0 for ri in r: y,z,w = (y+x*ri)%MOD, (z+y*ri)%MOD, (w+z*ri)%MOD print(w)