#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
template <typename T>
inline int mid(T &a, T &b) {
  return (a + b) / 2;
}
template <typename T>
inline int lchild(T &a) {
  return (2 * a);
}
template <typename T>
inline int rchild(T &a) {
  return (2 * a + 1);
}
template <typename T>
inline int parent(T &a) {
  return a / 2;
}
vector<bool> primes(100000, true);
void seive(int n) {
  primes[0] = primes[1] = false;
  for (int i = 4; i < n; i += 2) primes[i] = false;
  for (int i = 3; i * i <= n; i += 2) {
    if (primes[i])
      for (int j = i * i; j < n; j += i) primes[j] = false;
  }
}
ll binexp(ll a, ll b, ll mod = 1e9 + 7) {
  if (b == 0) return 1;
  ll sem = binexp(a, b / 2, mod);
  if (b & 1)
    return (a * (sem * sem) % mod) % mod;
  else
    return (sem * sem) % mod;
}
int find(int a, vi &parents) {
  if (a == parents[a]) {
    return a;
  }
  vi childs;
  while (a != parents[a]) {
    childs.push_back(a);
    a = parents[a];
  }
  for (int i = 0; i < childs.size(); ++i) parents[childs[i]] = a;
  return a;
}
void unionf(int a, int b, vi &parents, vi &ranks) {
  a = find(a, parents);
  b = find(b, parents);
  if (a == b)
    return;
  else {
    if (ranks[a] < ranks[b]) {
      parents[a] = b;
    } else if (ranks[b] < ranks[a]) {
      parents[b] = a;
    } else {
      parents[a] = b;
      ranks[b]++;
    }
  }
}
typedef struct {
  int x, y;
} point;
typedef struct {
  int start;
  int end;
  int weight;
} Edge;
struct Node {
  int data;
  struct Node *left, *right;
  Node(int data) {
    this->data = data;
    left = right = NULL;
  }
};
const int N = 1e5 + 5;
int segtree[4 * N];
int build(int i, int l, int r, int arr[]) {
  if (l == r) {
    segtree[i] = arr[l];
    return segtree[i];
  }
  segtree[i] = build(lchild(i), l, mid(l, r), arr) +
               build(rchild(i), mid(l, r) + 1, r, arr);
  return segtree[i];
}
void update(int i, int tl, int tr, int ind, int val) {
  if (tl == ind && tr == ind) {
    segtree[i] = val;
    return;
  }
  if (ind > tr || ind < tl) {
    return;
  }
  int tm = mid(tl, tr);
  update(lchild(i), tl, tm, ind, val);
  update(rchild(i), tm + 1, tr, ind, val);
  segtree[i] = segtree[lchild(i)] + segtree[rchild(i)];
}
int query(int i, int tl, int tr, int l, int r) {
  if (tl > r || tr < l) return 0;
  if (l <= tl && tr <= r) return segtree[i];
  int tm = mid(tl, tr);
  int ans = 0;
  ans += query(lchild(i), tl, tm, l, r);
  ans += query(rchild(i), tm + 1, tr, l, r);
  return ans;
}
void solve() {}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int k = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] != '4' and s[i] != '7') {
      cout << "NO" << endl;
      return 0;
    } else if (i < n / 2) {
      k += s[i];
    } else {
      k -= s[i];
    }
  }
  cout << (k == 0 ? "YES" : "NO") << endl;
}
