#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f, N = 2e6 + 5, MOD = 1e9 + 7;
const long long INF_LL = 0x3f3f3f3f3f3f3f3fLL;
template <typename T>
inline int getplc(T x, int y) {
  return (x >> y) & 1;
}
template <typename T>
T square(T x) {
  return x * x;
}
long long qpow(long long a, long long b = MOD - 2, long long _MOD = MOD) {
  long long res = 1;
  for (; b; b >>= 1, a = a * a % _MOD) {
    if (b & 1) res = res * a % _MOD;
  }
  return res;
}
template <typename T>
T Smax(T x) {
  return x;
}
template <typename T, typename... Args>
T Smax(T a, Args... args) {
  return max(a, Smax(args...));
}
template <typename T>
T Smin(T x) {
  return x;
}
template <typename T, typename... Args>
T Smin(T a, Args... args) {
  return min(a, Smin(args...));
}
template <typename T>
void errl(istream_iterator<string> it) {}
template <typename T, typename... Args>
void errl(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  errl(++it, args...);
}
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << "=" << a << " # ";
  err(++it, args...);
}
map<pair<int, int>, vector<pair<int, int> > > has;
int col[N], vis[N], w[N], ok;
struct node {
  int x, fa, siz, rnk;
} sta[N];
int ss;
class Union_set {
 public:
  int fa[N], siz[N], rnk[N], n;
  void recover(int cur) {
    while (ss != cur) {
      auto t = sta[ss--];
      fa[t.x] = t.fa;
      siz[t.x] = t.siz;
      rnk[t.x] = t.rnk;
    }
  }
  void init(int _n) {
    n = _n;
    for (int i = 1; i <= n; i++) fa[i] = i, siz[i] = 1, rnk[i] = 0;
  }
  int find(int x) { return fa[x] != x ? find(fa[x]) : x; }
  int getrnk(int x) {
    if (x == fa[x]) return rnk[x];
    int t = getrnk(fa[x]);
    return rnk[x] ^ t;
  }
  int Union(int x, int y) {
    int fx = find(x), fy = find(y);
    if (fx == fy) return getrnk(x) != getrnk(y);
    if (siz[fx] > siz[fy]) swap(fx, fy);
    sta[++ss] = (node){fx, fa[fx], siz[fx], rnk[fx]};
    sta[++ss] = (node){fy, fa[fy], siz[fy], rnk[fy]};
    fa[fx] = fy;
    siz[fy] += fx;
    rnk[fx] = getrnk(x) ^ getrnk(y) ^ 1;
    return 1;
  }
} us;
int suc[N];
void Solve() {
  int n, m, k;
  cin >> n >> m >> k;
  long long ans = 0;
  for (int i = 1; i <= k; i++) suc[i] = 1;
  for (int i = 1; i <= n; i++) {
    cin >> col[i];
  }
  us.init(n);
  for (int i = 1; i <= m; i++) {
    int u, v, cu, cv;
    cin >> u >> v;
    cu = col[u], cv = col[v];
    if (cu == cv) {
      suc[cu] &= us.Union(u, v);
    } else {
      if (cu > cv) swap(cu, cv);
      has[make_pair(cu, cv)].push_back({u, v});
    }
  }
  int all = 0;
  for (int i = 1; i <= k; i++)
    if (suc[i]) all++;
  ans = (long long)all * (all - 1) / 2;
  for (auto p : has) {
    int u = p.first.first, v = p.first.second;
    if (suc[u] == 0 || suc[v] == 0) {
      continue;
    }
    auto &edge = p.second;
    int cur = ss;
    ok = 1;
    for (auto e : edge) {
      ok &= us.Union(e.first, e.second);
      if (!ok) break;
    }
    if (!ok) ans--;
    us.recover(cur);
  }
  cout << ans << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  Solve();
  return 0;
}
