#include <bits/stdc++.h>
using namespace std;
int main() {
  int cou;
  int i, k, j, t, temp, q;
  int n, d;
  int count = 2;
  cin >> n;
  vector<int> vec;
  for (i = 0; i < n; i++) {
    cin >> temp;
    vec.push_back(temp);
  }
  int p_ar[100005] = {0};
  int q_ar[100005] = {0};
  q_ar[vec[n - 1]] = 1;
  long long int ans = 0;
  int n_diff = 1;
  for (j = n - 2; j >= 0; j--) {
    ans += (n_diff - p_ar[vec[j]]);
    p_ar[vec[j]] = n_diff;
    if (!q_ar[vec[j]]) n_diff++;
    q_ar[vec[j]] = 1;
  }
  cout << ans << endl;
  return 0;
}
