#include <bits/stdc++.h>
using namespace std;
const int NMAX = 1e5 + 17;
int b[NMAX];
int a[NMAX];
set<int> S;
int n;
bitset<10 * NMAX> bit;
long long ans;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  if (n < 2) return cout << 0, 0;
  for (int i = n; i >= 1; i--) {
    b[i] = S.size();
    S.insert(a[i]);
  }
  for (int i = 1; i <= n; i++) {
    if (!bit[a[i]]) {
      ans += b[i];
      bit[a[i]] = 1;
    }
  }
  cout << ans;
}
