#include <bits/stdc++.h>
using namespace std;
int MOD = 1e9 + 7;
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int x1 = n / 2;
  int ans1 = 0;
  while (x1--) {
    char x;
    cin >> x;
    if (x != '4' && x != '7') {
      ans1 = INT16_MAX;
    }
    ans1 += x - '0';
    n--;
  }
  while (n--) {
    char x;
    cin >> x;
    if (x != '4' && x != '7') {
      ans1 = INT16_MAX;
    }
    ans1 -= x - '0';
  }
  if (ans1 == 0) {
    cout << "YES";
    return 0;
  }
  cout << "NO";
  return 0;
}
