#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  long long int* a = new long long int[n];
  set<long long int> st;
  for (long long int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  bool* visited = new bool[100001];
  for (long long int i = 0; i < 100001; ++i) {
    visited[i] = false;
  }
  long long int ans = 0;
  long long int* uniq = new long long int[n];
  for (long long int i = n - 1; i >= 0; i--) {
    st.insert(a[i]);
    uniq[i] = st.size();
  }
  for (long long int i = 0; i < n - 1; ++i) {
    if (visited[a[i]] == false) {
      visited[a[i]] = true;
      ans += uniq[i + 1];
    }
  }
  cout << ans << endl;
  return 0;
}
