AlgoUniversity
  • Go Back
Discussion
Unique Subsequence :

Author

Akshay Sharma

Difficulty Level : Hard

Submissions : 69

Asked In : relevel

Marks :100

: 2 | : 1

Antro and his girlfriend decided to move their relationship to the next level and bought an array from a nearby array shop. As you have already guessed both of them are programmers.

A subsequence is a sequence that can be derived from the given array by deleting zero or more elements (not all) without changing the order of the remaining elements.

A unique subsequence is a subsequence such that all its elements are pairwise distinct.

Now to impress his girlfriend Antonio has to tell the number of ways to choose the unique/Distinct subsequence from this array. Antonio is facing difficulties with this and needs to help him!

Input

The first line contains a single Integer N ($$$1 \le N \le 1e5$$$)

The next line contains N space-separated integers denoting the elements of the array Antonio and his girlfriend bought ($$$1 \le A_i \le 1e6$$$)

Output

Print the total number of ways to choose a unique subsequence from the given array. As the answer can be very large print it modulo 10^9+7.

Examples

Input
3
1 2 1
Output
6
Input
4
1 1 1 1
Output
4

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.