#include <bits/stdc++.h>
using namespace std;
using ii = pair<int, int>;
using ll = long long;
constexpr int MAXN = 500005;
namespace dsu {
stack<array<int, 5>> st;
int sz[MAXN], c[MAXN];
bool bipartite[MAXN];
array<int, 2> f[MAXN];
void init() {
  for (int i = 0; i < MAXN; ++i) {
    c[i] = 0;
    bipartite[i] = true;
    sz[i] = 1;
    f[i] = {i, 0};
  }
}
void rollback(int it = 2) {
  if (it <= 0) return;
  int u = st.top()[0];
  bipartite[u] = st.top()[1];
  sz[u] = st.top()[2];
  f[u] = {st.top()[3], st.top()[4]};
  st.pop();
  rollback(it - 1);
}
array<int, 2> find(int x) {
  if (x == f[x][0]) {
    return {x, 0};
  } else {
    auto p = find(f[x][0]);
    return {p[0], f[x][1] ^ p[1]};
  }
}
bool join(int a, int b) {
  auto x = find(a), y = find(b);
  st.push({x[0], bipartite[x[0]], sz[x[0]], f[x[0]][0], f[x[0]][1]});
  st.push({y[0], bipartite[y[0]], sz[y[0]], f[y[0]][0], f[y[0]][1]});
  if (x[0] == y[0]) {
    if (x[1] == y[1]) {
      bipartite[x[0]] = false;
    }
  } else {
    if (sz[x[0]] < sz[y[0]]) swap(x, y);
    bipartite[x[0]] &= bipartite[y[0]];
    sz[x[0]] += sz[y[0]];
    f[y[0]] = {x[0], x[1] ^ y[1] ^ 1};
  }
  return bipartite[x[0]];
}
}  // namespace dsu
vector<int> lol[MAXN];
vector<array<int, 2>> e[MAXN];
int group[MAXN];
bool gb[MAXN];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n, m, g;
  cin >> n >> m >> g;
  for (int i = 1; i <= n; ++i) {
    cin >> group[i];
    lol[group[i]].push_back(i);
  }
  dsu::init();
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    if (group[a] == group[b]) {
      dsu::join(a, b);
    } else {
      if (group[a] > group[b]) swap(a, b);
      assert(group[a] < group[b]);
      e[group[a]].push_back({a, b});
    }
  }
  int tot = 0;
  for (int i = 1; i <= g; ++i) {
    gb[i] = true;
    for (auto u : lol[i]) {
      gb[i] &= dsu::bipartite[u];
    }
    if (gb[i]) tot++;
  }
  ll ans = (1LL * tot * (tot - 1)) / 2LL;
  for (int i = 1; i <= g; ++i) {
    if (!gb[i]) continue;
    sort(e[i].begin(), e[i].end(),
         [](const array<int, 2>& a, const array<int, 2>& b) -> bool {
           return group[a[1]] < group[b[1]];
         });
    const int sz = (int)e[i].size();
    for (int j = 0, k; j < sz; j = k) {
      for (k = j; k < sz && group[e[i][k][1]] == group[e[i][j][1]]; ++k)
        ;
      if (gb[group[e[i][j][1]]]) {
        bool ok = true;
        int c = 0;
        for (int p = j; p < k; ++p) {
          int u = e[i][p][0], v = e[i][p][1];
          ok &= dsu::join(u, v);
          c++;
        }
        if (!ok) ans--;
        while (c--) dsu::rollback();
      }
    }
  }
  cout << ans << '\n';
  return 0;
}
