#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int a[maxn], vis[maxn], num[maxn];
int main() {
  int n;
  long long ans = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = n; i >= 2; i--) {
    if (!vis[a[i]]) {
      num[i - 1] = num[i] + 1;
      vis[a[i]] = 1;
    } else
      num[i - 1] = num[i];
  }
  memset(vis, 0, sizeof(vis));
  for (int i = 1; i <= n - 1; i++) {
    if (!vis[a[i]]) {
      ans += num[i];
      vis[a[i]]++;
    }
  }
  cout << ans << endl;
  return 0;
}
