#include <bits/stdc++.h>
using namespace std;
struct data {
  int s, f, r;
  long long int c;
  data() {}
  data(int __s, int __f, long long int __c, int __r) {
    s = __s;
    f = __f;
    c = __c;
    r = __r;
  }
};
vector<data> trucks;
int n, m;
long long int a[250005], c[250005];
int s[250005], f[250005], r[250005];
bool check(int i, long long int V) {
  int pos = s[i];
  int R = r[i];
  int initPos = pos;
  while (pos <= f[i] && R >= 0) {
    long long int u = V / c[i];
    int dist = a[pos];
    while (dist + u >= a[pos] && pos <= f[i]) pos++;
    pos--;
    if (pos == initPos) break;
    R--;
  }
  if (pos == f[i]) return 1;
  return 0;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  srand(time(NULL));
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= m; i++) {
    int s, f, r;
    long long int c;
    cin >> s >> f >> c >> r;
    trucks.push_back(data(s, f, c, r));
  }
  random_shuffle(trucks.begin(), trucks.end());
  int C = 0;
  for (auto i : trucks) {
    C++;
    s[C] = i.s;
    f[C] = i.f;
    c[C] = i.c;
    r[C] = i.r;
  }
  long long int res = 0;
  for (int i = 1; i <= m; i++) {
    if (!check(i, res)) {
      long long int L = res + 1, R = 1e18 + 10;
      while (L < R) {
        long long int mid = (L + R) / 2;
        if (check(i, mid)) {
          R = mid;
        } else
          L = mid + 1;
      }
      res = L;
    }
  }
  cout << res << endl;
  return 0;
}
