#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 4;
int n;
int arr[maxn];
int dp[maxn];
bool vis[maxn];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  for (int i = n - 1; i >= 0; --i) {
    if (vis[arr[i]] == 0)
      dp[i] = dp[i + 1] + 1, vis[arr[i]] = 1;
    else
      dp[i] = dp[i + 1];
  }
  long long ans = 0;
  memset(vis, 0, sizeof(vis));
  for (int i = 0; i < n; ++i) {
    if (vis[arr[i]] == 0) ans += dp[i + 1], vis[arr[i]] = 1;
  }
  cout << ans << '\n';
}
