#include <bits/stdc++.h>
using namespace std;
int a[100100];
int num[100100];
int main() {
  set<int> s;
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = n; i >= 1; i--) {
    s.insert(a[i]);
    num[i] = s.size();
  }
  s.clear();
  long long sum = 0;
  for (int i = 1; i <= n; i++) {
    if (s.find(a[i]) == s.end()) {
      s.insert(a[i]);
      sum += num[i + 1];
    }
  }
  cout << sum << endl;
}
