#include <bits/stdc++.h>
using namespace std;
const int inf = 0x7f7f7f7f;
int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1};
int arr[100005];
set<int> st;
map<int, int> mp;
map<int, int> pos;
int main() {
  int n, x;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    if (mp[arr[i]] == 0) {
      mp[arr[i]] = 1;
      pos[i] = 1;
    }
  }
  long long res = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (pos[i]) {
      res = res + st.size();
    }
    st.insert(arr[i]);
  }
  cout << res << endl;
  return 0;
}
