#include <bits/stdc++.h>
using namespace std;
template <class Type>
long long quick_pow(Type x, Type y, Type Mod) {
  long long res = 1;
  while (y) {
    if (y & 1) res = res * x % Mod;
    x = x * x % Mod, y >>= 1;
  }
  return res;
}
template <class Type>
long long inv(Type x, Type Mod) {
  return quick_pow(x, Mod - 2, Mod);
}
namespace IO {
template <class T>
inline void read(T &x) {
  x = 0;
  int f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch <= '9' && ch >= '0') x = x * 10 + ch - '0', ch = getchar();
  x *= f;
}
};  // namespace IO
using namespace IO;
const int N = 2000005;
int n, m, K, fa[N], rnk[N], c[N], indx[N][2], Indx;
struct E {
  int u, v;
} e[N];
stack<pair<int *, int>> stk;
int find(int x) {
  while (x ^ fa[x]) x = fa[x];
  return x;
}
void Merge(int x, int y) {
  x = find(x), y = find(y);
  if (x == y) return;
  if (rnk[x] <= rnk[y]) {
    stk.push(make_pair(fa + x, fa[x]));
    fa[x] = y;
    if (rnk[x] == rnk[y]) {
      stk.push(make_pair(rnk + y, rnk[y]));
      rnk[y]++;
    }
  } else {
    stk.push(make_pair(fa + y, fa[y]));
    fa[y] = x;
  }
}
inline void add(int x, int y) {
  x = find(x), y = find(y);
  if (x == y) return;
  if (rnk[x] <= rnk[y]) {
    fa[x] = y;
    if (rnk[x] == rnk[y]) rnk[y]++;
  } else
    fa[y] = x;
}
vector<int> qry, v[N];
map<pair<int, int>, int> Map;
int vcnt, tag[N];
pair<int, int> Pair[N];
int main() {
  read(n), read(m), read(K);
  for (int i = (1); i <= (n); ++i) read(c[i]);
  for (int i = (1); i <= (n); ++i) {
    indx[i][0] = ++Indx;
    indx[i][1] = ++Indx;
  }
  for (int i = (1); i <= (Indx); ++i) fa[i] = i, rnk[i] = 0;
  for (int i = (1); i <= (m); ++i) {
    read(e[i].u), read(e[i].v);
    if (c[e[i].u] == c[e[i].v]) {
      add(indx[e[i].u][0], indx[e[i].v][1]);
      add(indx[e[i].u][1], indx[e[i].v][0]);
    } else
      qry.push_back(i);
  }
  for (int i = (1); i <= (n); ++i) {
    if (find(indx[i][0]) == find(indx[i][1])) tag[c[i]] = 1;
  }
  for (int i = (K); i >= (1); --i)
    if (tag[i]) K--;
  long long ans = 1LL * K * (K - 1) / 2;
  for (auto y : qry) {
    int U = c[e[y].u], V = c[e[y].v];
    if (tag[U] || tag[V]) continue;
    if (U > V) swap(U, V);
    if (!Map[make_pair(U, V)])
      Map[make_pair(U, V)] = ++vcnt, Pair[vcnt] = make_pair(U, V);
    int pos = Map[make_pair(U, V)];
    v[pos].push_back(y);
  }
  for (int i = (1); i <= (vcnt); ++i) {
    for (auto y : v[i]) {
      int U = e[y].u, V = e[y].v;
      Merge(indx[U][0], indx[V][1]);
      Merge(indx[U][1], indx[V][0]);
      if (find(indx[U][0]) == find(indx[U][1])) {
        ans--;
        break;
      }
      if (find(indx[V][0]) == find(indx[V][1])) {
        ans--;
        break;
      }
    }
    while (!stk.empty()) {
      int *F = stk.top().first, S = stk.top().second;
      stk.pop();
      *F = S;
    }
  }
  cout << ans << endl;
  return 0;
}
