#include <bits/stdc++.h>
using namespace std;
int a[100010], b1[100010];
bool b[100010], c[100010];
int main() {
  int n;
  cin >> n;
  b1[n + 1] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = n; i >= 1; i--) {
    b1[i] = b1[i + 1];
    if (b[a[i]] == 0) {
      b[a[i]] = 1;
      b1[i]++;
    }
  }
  long long int ans = 0;
  for (int i = 1; i < n; i++) {
    if (c[a[i]] == 0) {
      c[a[i]] = 1;
      ans += b1[i + 1];
    }
  }
  cout << ans << endl;
}
